Skip to content

Commit a321f07

Browse files
test: ignore TypeScript errors in 'node_modules'
1 parent 079649e commit a321f07

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

jest.config.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { createConfig } = require('@openedx/frontend-build');
22

3-
module.exports = createConfig('jest', {
3+
const mergedConfig = createConfig('jest', {
44
setupFilesAfterEnv: [
55
'jest-expect-message',
66
'<rootDir>/src/setupTest.js',
@@ -16,6 +16,24 @@ module.exports = createConfig('jest', {
1616
// This alias is used for plugins in the plugins/ folder only.
1717
'^CourseAuthoring/(.*)$': '<rootDir>/src/$1',
1818
},
19-
modulePathIgnorePatterns: [
20-
],
19+
modulePathIgnorePatterns: [],
2120
});
21+
22+
// Override ts-jest config: When transforming .ts files to .js for test purposes,
23+
// don't report TypeScript errors for files in `node_modules/` (or any non-test files).
24+
// Without this, we were seeing TypeScript errors from
25+
// node_modules/@edx/frontend-component-header/dist/studio-header/StudioHeader.tsx
26+
// cause the tests to fail, because they are included in `transformIgnorePatterns`.
27+
// -> If you can delete the following lines and the tests still pass, then feel free
28+
// to remove this whole override. It's only necessary now while StudioHeader has some
29+
// typing issues.
30+
mergedConfig.transform['^.+\\.[tj]sx?$'] = [
31+
'ts-jest',
32+
{
33+
diagnostics: {
34+
exclude: ['!**/*.test.*'],
35+
},
36+
},
37+
];
38+
39+
module.exports = mergedConfig;

0 commit comments

Comments
 (0)