Skip to content

Commit 58a57a6

Browse files
committed
Update autocomplete-client jest config
1 parent ea8f387 commit 58a57a6

File tree

3 files changed

+97
-993
lines changed

3 files changed

+97
-993
lines changed
Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,59 @@
1-
const ignoreFiles = ['<rootDir>(/.*)*/assets', 'test.utils']
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
const baseConfig = {
3+
coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'],
4+
testPathIgnorePatterns: ['<rootDir>(/.*)*/assets', 'test.utils'],
5+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
6+
// Transform all JS and TS files with `ts-jest`
7+
transform: {
8+
'^.+.(ts|js)?$': [
9+
'ts-jest',
10+
{
11+
// use ESM because we're loading the ESM build of `meilisearch-js`
12+
useESM: true,
13+
},
14+
],
15+
},
16+
// Allow `ts-jest` to resolve relative JS imports, e.g., `./folder/index.js`
17+
// See https://github.com/kulshekhar/ts-jest/issues/1057
18+
moduleNameMapper: {
19+
'(.+)\\.js': '$1',
20+
},
21+
// Treat TS as ESM. JS is automatically treated as ESM
22+
// if package.json has `"type": "module"`
23+
extensionsToTreatAsEsm: ['.ts'],
24+
}
225

3-
module.exports = {
26+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
27+
export default {
428
verbose: true,
529
watchPlugins: [
630
'jest-watch-typeahead/filename',
731
'jest-watch-typeahead/testname',
832
],
933
collectCoverage: true,
10-
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
1134
projects: [
1235
{
13-
globals: {
14-
'ts-jest': { tsconfig: 'tsconfig.test.json' },
15-
fetch: globalThis.fetch,
16-
},
17-
preset: 'ts-jest',
36+
...baseConfig,
37+
// globals: {
38+
// 'ts-jest': { tsconfig: 'tsconfig.test.json' },
39+
// fetch: globalThis.fetch,
40+
// },
41+
// preset: 'ts-jest',
1842
displayName: 'dom',
19-
testPathIgnorePatterns: [...ignoreFiles],
20-
coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'],
43+
// testPathIgnorePatterns: [...ignoreFiles],
44+
// coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'],
2145
},
2246
{
23-
globals: {
24-
'ts-jest': { tsconfig: 'tsconfig.test.json' },
25-
fetch: globalThis.fetch,
26-
},
27-
preset: 'ts-jest',
47+
...baseConfig,
48+
// globals: {
49+
// 'ts-jest': { tsconfig: 'tsconfig.test.json' },
50+
// fetch: globalThis.fetch,
51+
// },
52+
// preset: 'ts-jest',
2853
displayName: 'node',
2954
testEnvironment: 'node',
30-
coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'],
31-
testPathIgnorePatterns: [...ignoreFiles],
55+
// coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'],
56+
// testPathIgnorePatterns: ['<rootDir>(/.*)*/assets', 'test.utils'],
3257
},
3358
],
3459
}

packages/autocomplete-client/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test:types": "yarn tsc",
2020
"version": "node scripts/update_version.js"
2121
},
22+
"type": "module",
2223
"main": "./dist/autocomplete-client.umd.js",
2324
"module": "./dist/autocomplete-client.esm.js",
2425
"browser": "./dist/autocomplete-client.umd.js",
@@ -56,13 +57,13 @@
5657
"@babel/preset-env": "^7.20.2",
5758
"@rollup/plugin-commonjs": "^17.1.0",
5859
"@rollup/plugin-node-resolve": "^11.2.0",
59-
"@types/jest": "^27.0.2",
60+
"@types/jest": "^29.5.14",
6061
"babel-jest": "^27.2.2",
6162
"concurrently": "^7.1.0",
6263
"cssnano": "^4.1.10",
6364
"eslint-config-meilisearch": "*",
6465
"instantsearch.js": "^4.56.2",
65-
"jest": "^27.2.2",
66+
"jest": "^29.7.0",
6667
"jest-watch-typeahead": "^0.6.3",
6768
"regenerator-runtime": "^0.13.7",
6869
"rollup": "^2.79.2",
@@ -71,7 +72,7 @@
7172
"rollup-plugin-terser": "^7.0.0",
7273
"rollup-plugin-typescript2": "^0.32.1",
7374
"shx": "^0.3.4",
74-
"ts-jest": "^27.0.7",
75+
"ts-jest": "^29.2.5",
7576
"tslib": "^2.6.1",
7677
"typescript": "^4.9.3"
7778
}

0 commit comments

Comments
 (0)