Created
October 25, 2021 15:24
-
-
Save metabacalhau/5652b79c45a8915d02e0ed69abd4906a to your computer and use it in GitHub Desktop.
Jest transformation issue on Windows (slashes in file paths)
This file contains hidden or 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
| // Problem with tests on Windows: Jest encountered an unexpected token... SyntaxError: Unexpected token... | |
| // Reason: Node.js treats slashes differently on Unix => foo/bar and Windows => foo\\bar | |
| // Solution: Use Regex for both systems [/\\\\] | |
| module.exports = { | |
| transform: { | |
| 'foo[/\\\\]bar[/\\\\].*\\.svg$': require.resolve('./mocks/svg.js'), | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment