Skip to content

Commit

Permalink
fix: add file transform
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofan2406 committed Nov 25, 2022
1 parent 2e0ed37 commit 8b807c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions config/fileTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');

module.exports = {
process(_sourceText, sourcePath) {
return {
code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`,
};
},
};
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module.exports = {
verbose: true,
moduleFileExtensions: ['js', 'jsx', 'json'],
transform: {
'^.+\\.(js|jsx)?$': 'babel-jest',
'^.+\\.css$': '<rootDir>/config/cssTransform.js',
'\\.(js|jsx)?$': 'babel-jest',
'\\.css$': '<rootDir>/config/cssTransform.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/config/fileTransform.js',
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$'],
clearMocks: true,
Expand Down

0 comments on commit 8b807c8

Please sign in to comment.