Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save metabacalhau/5652b79c45a8915d02e0ed69abd4906a to your computer and use it in GitHub Desktop.

Select an option

Save metabacalhau/5652b79c45a8915d02e0ed69abd4906a to your computer and use it in GitHub Desktop.
Jest transformation issue on Windows (slashes in file paths)
// 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