Skip to content

Commit

Permalink
chore: using swc-jest instead of esbuild jest (#1427)
Browse files Browse the repository at this point in the history
* chore: using swc-jest instead of esbuild jest

* chore: update lock

* chore: upd
  • Loading branch information
chenjiahan authored Jul 29, 2022
1 parent 1c9199d commit 5ca8ed6
Show file tree
Hide file tree
Showing 9 changed files with 380 additions and 250 deletions.
12 changes: 11 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ module.exports = {
],
coveragePathIgnorePatterns: ['/node_modules/', '/fixtures/'],
transform: {
'\\.[jt]sx?$': 'esbuild-jest',
'\\.[jt]sx?$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
},
},
},
],
},
moduleNameMapper: {},
globals: {},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@
"@modern-js/plugin-jarvis": "workspace:*",
"@modern-js/tsconfig": "workspace:*",
"@scripts/build": "workspace:*",
"@swc/core": "^1.2.220",
"@swc/jest": "^0.2.22",
"babel-plugin-module-resolver": "^4.1.0",
"btsm": "2.2.2",
"enhanced-resolve": "^5.9.2",
"esbuild": "^0.14.38",
"esbuild-jest": "0.5.0",
"husky": "^8.0.0",
"jest": "^27.5.1",
"wireit": "^0.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const post = createRequest('/api/:id/origin/foo', 'POST', process.env.POR
expect(result.value)
.toMatch(`import { createRequest } from '@modern-js/create-request';
export const DELETE = createRequest('/normal/origin', 'DELETE', process.env.PORT || 3000);
export default createRequest('/normal/origin', 'GET', process.env.PORT || 3000);
export const DELETE = createRequest('/normal/origin', 'DELETE', process.env.PORT || 3000);
export const putRepo = createRequest('/put-repo', 'PUT', process.env.PORT || 3000);
`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/server/bff-core/tests/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('test api router', () => {
const handlerInfos = apiRouter.getSingleModuleHandlers(apiFile);
const methods = handlerInfos?.map(handlerInfo => handlerInfo.httpMethod);
expect(methods?.length).toBe(3);
expect(methods).toEqual(['DELETE', 'GET', 'PUT']);
expect(methods).toEqual(['GET', 'DELETE', 'PUT']);
});

test('getAllAPIFiles', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/create-request/tests/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import nock from 'nock';
import { run } from '@modern-js/utils/ssr';
// 如果通过 default 引入会报 "Property exprName of TSTypeQuery expected node to be of a type ["TSEntityName","TSImportType"] but instead got "MemberExpression"
import * as fetch from 'node-fetch';
import type { Response } from 'node-fetch';
import { Response } from 'node-fetch';
import { configure, createRequest } from '../src/node';

describe('configure', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/server/server/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @jest-environment jsdom
*/
import { formatURL } from '../src/hmr-client/createSocketUrl';

describe('formatURL', () => {
Expand Down
Loading

0 comments on commit 5ca8ed6

Please sign in to comment.