Skip to content

Commit

Permalink
test: avoid running codemod tests in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Sep 19, 2024
1 parent dca98de commit cacb67c
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default [
ignores: [
'docs/**/*.js',
'packages/*/test/fixtures/*',
'packages/**/__test__/fixtures/*',
'packages/**/__tests__/fixtures/*',
'**/dist/**/*',
'packages/fetch-mock/types/index.test-d.ts',
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test": "vitest . --ui --exclude=packages/jest/src/__tests__/*",
"test:ci": "vitest . --reporter=junit --outputFile=test-results/junit.xml --coverage.provider=istanbul --exclude=packages/jest/src/__tests__/*",
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js packages/jest",
"test:browser": "vitest . --browser.enabled --browser.name chromium --browser.provider playwright --exclude=packages/jest/src/__tests__/*",
"test:browser": "vitest . --browser.enabled --browser.name chromium --browser.provider playwright --exclude=packages/{jest,codemods}/src/__tests__/*",
"coverage:send": "cat ./coverage/lcov.info | coveralls",
"compat:module": "npm run compat:module -w import-compat"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const exec = promisify(callbackExec);
describe('integration', () => {
it('can operate on typescript', async () => {
const { stdout } = await exec(
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/typescript.ts',
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__tests__/fixtures/typescript.ts',
);
expect(stdout).toContain(`import fetchMock from 'fetch-mock';
function helper (res: number): void {
Expand All @@ -15,15 +15,15 @@ function helper (res: number): void {
});
it('can operate on jsx', async () => {
const { stdout } = await exec(
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/jsx.jsx',
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__tests__/fixtures/jsx.jsx',
);
expect(stdout).toContain(`import fetchMock from 'fetch-mock';
fetchMock.route("blah", <div>Content</div>);`);
});

it('can operate on tsx', async () => {
const { stdout } = await exec(
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/tsx.tsx',
'jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__tests__/fixtures/tsx.tsx',
);
expect(stdout).toContain(`import fetchMock from 'fetch-mock';
function helper (res: number): void {
Expand All @@ -32,7 +32,7 @@ function helper (res: number): void {
});
it('allow passing in one or more additional variable names for fetch-mock', async () => {
const { stdout } = await exec(
'FM_VARIABLES=fm1,fm2 jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__test__/fixtures/extra-vars.js',
'FM_VARIABLES=fm1,fm2 jscodeshift --parser ts -p -d -t ./packages/codemods/src/index.js ./packages/codemods/src/__tests__/fixtures/extra-vars.js',
);
expect(stdout).toContain(`const fetchMock = require('fetch-mock');
fetchMock.route('blah', 200);
Expand Down
File renamed without changes.

0 comments on commit cacb67c

Please sign in to comment.