Skip to content

Commit

Permalink
chore: update jest config to transform images
Browse files Browse the repository at this point in the history
  • Loading branch information
miracles1919 committed Mar 11, 2022
1 parent d21c298 commit c9e30e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fileTransformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path')

// https://jestjs.io/docs/code-transformation#transforming-images-to-their-path
module.exports = {
process(src, filename, config, options) {
return `module.exports = ${JSON.stringify(path.basename(filename))};`
},
}
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module.exports = {
moduleDirectories: ['node_modules', 'src/tests'],
transform: {
'^.+\\.(ts|tsx)?$': 'ts-jest/dist',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/fileTransformer.js',
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
Expand Down

0 comments on commit c9e30e6

Please sign in to comment.