Created
January 12, 2017 17:08
-
-
Save avaly/3ff041228a5c6f789119170c28a80367 to your computer and use it in GitHub Desktop.
jest-bug-json-transform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"foo": 123 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<foo> | |
123 | |
</foo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
process(src) { | |
console.log('jest-test-preprocessor', src); | |
return 'module.exports = ' + JSON.stringify('transformed-' + src.substr(0, 1)); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const json = require('./fixture.json'); | |
const xml = require('./fixture.xml'); | |
describe('jest-json', function () { | |
it('should transform JSON', function () { | |
console.log('json', json); | |
expect(json).toEqual('transformed-{'); | |
}); | |
it('should transform XML', function () { | |
console.log('xml', xml); | |
expect(xml).toEqual('transformed-<'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "jest-test", | |
"version": "1.0.0", | |
"description": "", | |
"scripts": { | |
"test": "jest" | |
}, | |
"license": "ISC", | |
"devDependencies": { | |
"jest": "^18.1.0" | |
}, | |
"jest": { | |
"verbose": true, | |
"moduleFileExtensions": ["js"], | |
"transform": { | |
"\\.json$": "<rootDir>/jest-test-preprocessor.js", | |
"\\.xml$": "<rootDir>/jest-test-preprocessor.js" | |
} | |
} | |
} |
Author
avaly
commented
Jan 12, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment