Skip to content

Commit

Permalink
feat(config): add better support for TypeScript (#368)
Browse files Browse the repository at this point in the history
* feat(config): add support for typescript files

* feat(config): use more jest-preset
  • Loading branch information
wjhsf authored May 28, 2024
1 parent e6dd51f commit 0ef561b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,25 @@ function getCoveragePaths() {
}

const jestConfig = {
rootDir: PROJECT_ROOT,
moduleFileExtensions: ['js', 'html'],
// Inherited from @lwc/jest-preset
moduleFileExtensions: jestPreset.moduleFileExtensions || ['ts', 'js', 'html'],
testEnvironment: jestPreset.testEnvironment || 'jsdom',
transform: {
'^.+\\.(js|html|css)$': require.resolve('@lwc/jest-transformer'),
...jestPreset.transform,
'^.+\\.(js|ts|html|css)$': require.resolve('@lwc/jest-transformer'),
},
setupFilesAfterEnv: jestPreset.setupFilesAfterEnv || [],
snapshotSerializers: jestPreset.snapshotSerializers || [
require.resolve('@lwc/jest-serializer'),
],
// Specific to sfdx-lwc-jest
collectCoverageFrom: getCoveragePaths(),
resolver: path.join(__dirname, './resolver.js'),
rootDir: PROJECT_ROOT,
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/test/specs/'],
transformIgnorePatterns: [
'/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/lightning-stubs)/)',
],
setupFilesAfterEnv: jestPreset.setupFilesAfterEnv || [],
resolver: path.resolve(__dirname, './resolver.js'),
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/test/specs/'],
collectCoverageFrom: getCoveragePaths(),
snapshotSerializers: [require.resolve('@lwc/jest-serializer')],
};

const expectedApiVersion = '61.0';
Expand Down

0 comments on commit 0ef561b

Please sign in to comment.