Skip to content

Commit

Permalink
🧹 Use @swc/jest to speed up test runs (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 21, 2024
1 parent fa2e332 commit 462566c
Show file tree
Hide file tree
Showing 37 changed files with 379 additions and 189 deletions.
4 changes: 3 additions & 1 deletion packages/create-lz-oapp/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testTimeout: 15000,
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/create-lz-oapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
},
"devDependencies": {
"@layerzerolabs/io-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"@types/prompts": "^2.4.9",
"@types/react": "^17.0.74",
Expand All @@ -49,7 +51,6 @@
"prompts": "^2.4.2",
"react": "^17.0.2",
"tiged": "^2.12.5",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tsup": "~8.0.1",
"typescript": "^5.3.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools-evm-hardhat/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/devtools-evm-hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
"@layerzerolabs/lz-evm-sdk-v1": "~2.0.11",
"@layerzerolabs/test-devtools": "~0.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"fast-check": "^3.15.0",
"hardhat": "^2.19.4",
"hardhat-deploy": "^0.11.45",
"jest": "^29.7.0",
"p-memoize": "~4.0.1",
"sinon": "^17.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@
"@layerzerolabs/io-devtools": "~0.0.3",
"@layerzerolabs/lz-definitions": "~2.0.11",
"@layerzerolabs/test-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"fast-check": "^3.15.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
"@layerzerolabs/io-devtools": "~0.0.2",
"@layerzerolabs/lz-definitions": "~2.0.11",
"@layerzerolabs/test-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"fast-check": "^3.15.0",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/io-devtools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/io-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"winston": "^3.11.0"
},
"devDependencies": {
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/ink-gradient": "^2.0.4",
"@types/jest": "^29.5.11",
"@types/prompts": "^2.4.9",
Expand All @@ -52,7 +54,6 @@
"ink-table": "^3.1.0",
"jest": "^29.7.0",
"react": "^17.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

exports[`filesystem/filesystem importDefault should not work with a non-JS compatible file 1`] = `[SyntaxError: Invalid or unexpected token]`;

exports[`filesystem/filesystem importDefault should not work with an JS/ESM file 1`] = `[SyntaxError: Unexpected token 'export']`;

exports[`filesystem/filesystem importDefault should not work with an empty JSON file 1`] = `[SyntaxError: Unexpected end of JSON input]`;

exports[`filesystem/filesystem importDefault should work with a JS/CJS file 1`] = `
Expand All @@ -12,6 +10,12 @@ exports[`filesystem/filesystem importDefault should work with a JS/CJS file 1`]
}
`;

exports[`filesystem/filesystem importDefault should work with a JS/ESM file 1`] = `
{
"i am": "an object",
}
`;

exports[`filesystem/filesystem importDefault should work with a JSON file 1`] = `
{
"i am": "an object",
Expand Down
4 changes: 2 additions & 2 deletions packages/io-devtools/test/filesystem/filesystem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ describe('filesystem/filesystem', () => {
await expect(importDefault(fileName)).resolves.toMatchSnapshot()
})

it('should not work with an JS/ESM file', async () => {
it('should work with a JS/ESM file', async () => {
const fileName = configPathFixture('object.esm.js')

await expect(importDefault(fileName)).rejects.toMatchSnapshot()
await expect(importDefault(fileName)).resolves.toMatchSnapshot()
})

it('should work with a TS/CJS file', async () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/io-devtools/test/stdio/__snapshots__/printer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports[`stdio/printer printRecord should return a list of items with indices fo
├───┼──────────────────┤
│ 6 │ Symbol(oh hello) │
├───┼──────────────────┤
│ 7 │ () => { }
│ 7 │ ()=>{}
└───┴──────────────────┘"
`;

Expand All @@ -42,7 +42,7 @@ exports[`stdio/printer printRecord should return a list of items with indices fo
├───────────┼──────────────────┤
│ symbol │ Symbol(oh hello) │
├───────────┼──────────────────┤
│ function │ () => { }
│ function │ ()=>{}
└───────────┴──────────────────┘"
`;

Expand All @@ -64,7 +64,7 @@ exports[`stdio/printer printRecord should return a list of items with indices wi
├───┼──────────────────┤
│ 6 │ Symbol(oh hello) │
├───┼──────────────────┤
│ 7 │ () => { }
│ 7 │ ()=>{}
└───┴──────────────────┘"
`;

Expand All @@ -86,7 +86,7 @@ exports[`stdio/printer printRecord should return a list of items with indices wi
├───────────┼──────────────────┤
│ symbol │ Symbol(oh hello) │
├───────────┼──────────────────┤
│ function │ () => { }
│ function │ ()=>{}
└───────────┴──────────────────┘"
`;

Expand All @@ -106,7 +106,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
├──────────────┼──────────────────────────────────┤
│ symbol │ Symbol(oh hello) │
├──────────────┼──────────────────────────────────┤
│ function │ () => { }
│ function │ ()=>{}
├──────────────┼──────────────────────────────────┤
│ nestedArray │ ┌───┬──────────────────┐ │
│ │ │ 0 │ something │ │
Expand All @@ -123,7 +123,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
│ │ ├───┼──────────────────┤ │
│ │ │ 6 │ Symbol(oh hello) │ │
│ │ ├───┼──────────────────┤ │
│ │ │ 7 │ () => { } │ │
│ │ │ 7 │ ()=>{} │ │
│ │ └───┴──────────────────┘ │
├──────────────┼──────────────────────────────────┤
│ nestedObject │ ┌───────────┬──────────────────┐ │
Expand All @@ -141,7 +141,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
│ │ ├───────────┼──────────────────┤ │
│ │ │ symbol │ Symbol(oh hello) │ │
│ │ ├───────────┼──────────────────┤ │
│ │ │ function │ () => { } │ │
│ │ │ function │ ()=>{} │ │
│ │ └───────────┴──────────────────┘ │
└──────────────┴──────────────────────────────────┘"
`;
Expand All @@ -162,7 +162,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
├───┼──────────────────────────────────┤
│ 6 │ Symbol(oh hello) │
├───┼──────────────────────────────────┤
│ 7 │ () => { }
│ 7 │ ()=>{}
├───┼──────────────────────────────────┤
│ 8 │ ┌───┬──────────────────┐ │
│ │ │ 0 │ something │ │
Expand All @@ -179,7 +179,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
│ │ ├───┼──────────────────┤ │
│ │ │ 6 │ Symbol(oh hello) │ │
│ │ ├───┼──────────────────┤ │
│ │ │ 7 │ () => { } │ │
│ │ │ 7 │ ()=>{} │ │
│ │ └───┴──────────────────┘ │
├───┼──────────────────────────────────┤
│ 9 │ ┌───────────┬──────────────────┐ │
Expand All @@ -197,7 +197,7 @@ exports[`stdio/printer printRecord should return a nested list for a nested obje
│ │ ├───────────┼──────────────────┤ │
│ │ │ symbol │ Symbol(oh hello) │ │
│ │ ├───────────┼──────────────────┤ │
│ │ │ function │ () => { } │ │
│ │ │ function │ ()=>{} │ │
│ │ └───────────┴──────────────────┘ │
└───┴──────────────────────────────────┘"
`;
Expand Down
4 changes: 3 additions & 1 deletion packages/omnicounter-devtools-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/omnicounter-devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
"@layerzerolabs/protocol-devtools-evm": "~0.0.2",
"@layerzerolabs/ua-devtools": "~0.0.2",
"@layerzerolabs/ua-devtools-evm": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/omnicounter-devtools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/omnicounter-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"@layerzerolabs/devtools": "~0.0.2",
"@layerzerolabs/lz-definitions": "~2.0.11",
"@layerzerolabs/protocol-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/protocol-devtools-evm/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
workerThreads: true,
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/protocol-devtools-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@
"@layerzerolabs/lz-evm-sdk-v2": "~2.0.11",
"@layerzerolabs/protocol-devtools": "~0.0.2",
"@layerzerolabs/test-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"fast-check": "^3.15.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol-devtools/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
3 changes: 2 additions & 1 deletion packages/protocol-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
"@layerzerolabs/devtools": "~0.0.3",
"@layerzerolabs/lz-definitions": "~2.0.11",
"@layerzerolabs/test-devtools": "~0.0.2",
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"fast-check": "^3.15.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "~2.6.2",
"tsup": "~8.0.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/toolbox-foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
},
"dependencies": {},
"devDependencies": {
"@swc/core": "^1.3.104",
"@swc/jest": "^0.2.30",
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"solidity-bytes-utils": "^0.8.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tsup": "~8.0.1",
"typescript": "^5.3.3"
Expand Down
5 changes: 3 additions & 2 deletions packages/toolbox-hardhat/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
cache: false,
testEnvironment: 'node',
testTimeout: 15000,
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
};
Loading

0 comments on commit 462566c

Please sign in to comment.