update file mock to return file name

This commit is contained in:
John Mitchell
2018-11-02 16:32:51 -04:00
parent 90d1ab88b1
commit a670a73fd0
2 changed files with 9 additions and 3 deletions

View File

@@ -1 +1,7 @@
module.exports = 'test-file-stub'; const path = require('path');
module.exports = {
process (src, filename) {
return `module.exports=${JSON.stringify(path.basename(filename))};`;
},
};

View File

@@ -3,7 +3,6 @@ module.exports = {
'src/**/*.{js,jsx}' 'src/**/*.{js,jsx}'
], ],
moduleNameMapper: { moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|scss|less)$': '<rootDir>/__mocks__/styleMock.js' '\\.(css|scss|less)$': '<rootDir>/__mocks__/styleMock.js'
}, },
setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js', setupTestFrameworkScriptFile: '<rootDir>/jest.setup.js',
@@ -13,7 +12,8 @@ module.exports = {
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
testURL: 'http://127.0.0.1:3001', testURL: 'http://127.0.0.1:3001',
transform: { transform: {
'^.+\\.(js|jsx)$': 'babel-jest' '^.+\\.(js|jsx)$': 'babel-jest',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
}, },
transformIgnorePatterns: [ transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(?!(axios)/)(js|jsx)$' '[/\\\\]node_modules[/\\\\].+\\.(?!(axios)/)(js|jsx)$'