Skip to content

Commit 67d885c

Browse files
authored
chore: share test config among packages (#1170)
1 parent fb2ba56 commit 67d885c

File tree

12 files changed

+237
-543
lines changed

12 files changed

+237
-543
lines changed

packages/library/internal/jest/jest-dev.config.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/library/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
"scripts": {
3939
"compile:js": "tsup --config build-scripts/tsup.config.ts",
4040
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
41-
"dev": "jest -c ./internal/jest/jest-dev.config.ts --watch",
42-
"test:lint": "jest -c ./internal/jest/jest-lint.config.ts --silent",
43-
"test:prettier": "jest -c ./internal/jest/jest-prettier.config.ts --silent",
41+
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
42+
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
43+
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
4444
"test:treeshakability:browser": "agadoo dist/index.browser.js",
4545
"test:treeshakability:native": "agadoo dist/index.node.js",
4646
"test:treeshakability:node": "agadoo dist/index.native.js",
4747
"test:typecheck": "tsc --noEmit",
48-
"test:unit:browser": "jest -c ./internal/jest/jest-unit.config.browser.ts --silent",
49-
"test:unit:node": "jest -c ./internal/jest/jest-unit.config.node.ts --silent"
48+
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
49+
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
5050
},
5151
"author": "Solana Labs Maintainers <[email protected]>",
5252
"license": "MIT",
@@ -80,6 +80,7 @@
8080
"jest-runner-prettier": "^1.0.0",
8181
"postcss": "^8.4.12",
8282
"prettier": "^2.7.1",
83+
"test-config": "workspace:*",
8384
"ts-node": "^10.9.1",
8485
"tsconfig": "workspace:*",
8586
"tsup": "6.5.0",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Config } from 'jest';
2+
import path from 'path';
3+
4+
const config: Config = {
5+
projects: [
6+
path.resolve(__dirname, 'jest-lint.config.ts'),
7+
path.resolve(__dirname, 'jest-prettier.config.ts'),
8+
path.resolve(__dirname, 'jest-unit.config.browser.ts'),
9+
path.resolve(__dirname, 'jest-unit.config.node.ts'),
10+
],
11+
};
12+
13+
export default config;

packages/library/internal/jest/jest-lint.config.ts renamed to packages/test-config/jest-lint.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import type { Config } from 'jest';
22

33
const config: Config = {
44
displayName: 'ESLint',
5-
rootDir: '../../',
65
runner: 'eslint',
7-
testMatch: ['<rootDir>src/**/*.ts', '<rootDir>internal/**'],
6+
testMatch: ['<rootDir>src/**/*.ts'],
87
};
98

109
export default config;

packages/library/internal/jest/jest-prettier.config.ts renamed to packages/test-config/jest-prettier.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import type { Config } from 'jest';
33
const config: Config = {
44
displayName: 'Prettier',
55
moduleFileExtensions: ['js', 'ts', 'json', 'md'],
6-
rootDir: '../../',
76
runner: 'prettier',
8-
testMatch: ['<rootDir>README.md', '<rootDir>internal/**', '<rootDir>src/**', '<rootDir>*'],
7+
testMatch: ['<rootDir>/src/**', '<rootDir>*'],
98
};
109

1110
export default config;

packages/library/internal/jest/jest-unit.config.common.ts renamed to packages/test-config/jest-unit.config.common.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ const config: Config = {
44
globals: {
55
__DEV__: false,
66
},
7-
rootDir: '../../',
8-
roots: ['<rootDir>src/'],
7+
roots: ['<rootDir>/src/'],
98
transform: {
109
'^.+\\.(ts|js)$': [
1110
'@swc/jest',

packages/test-config/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "test-config",
3+
"version": "0.0.0",
4+
"private": true,
5+
"files": [
6+
"jest-dev.config.ts",
7+
"jest-lint.config.ts",
8+
"jest-prettier.config.ts",
9+
"jest-unit.config.browser.ts",
10+
"jest-unit.config.node.ts"
11+
],
12+
"peerDependencies": {
13+
"jest": "^29.3.1",
14+
"jest-environment-jsdom": "^29.3.1",
15+
"jest-runner-eslint": "^1.1.0",
16+
"jest-runner-prettier": "^1.0.0"
17+
},
18+
"devDependencies": {
19+
"jest": "^29.3.1",
20+
"tsconfig": "workspace:*"
21+
}
22+
}

packages/test-config/tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"display": "Test Config",
4+
"extends": "tsconfig/base.json"
5+
}

0 commit comments

Comments
 (0)