Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Jest encountered an unexpected token
  2.  
  3. This usually means that you are trying to import a file which Jest
  4. cannot parse, e.g. it's not plain JavaScript.
  5.  
  6. By default, if Jest sees a Babel config, it will use that to
  7. transform your files, ignoring "node_modules".
  8.  
  9. Here's what you can do:
  10. • To have some of your "node_modules" files transformed, you can
  11. specify a custom "transformIgnorePatterns" in your config.
  12. • If you need a custom transformation specify a "transform" option
  13. in your config.
  14. • If you simply want to mock your non-JS modules (e.g. binary
  15. assets) you can stub them out with the "moduleNameMapper" config
  16. option.
  17.  
  18. const esModules = ['@ionic', '@ionic-native',
  19. '@angular/core'].join('|');
  20.  
  21. module.exports = {
  22. globals: {
  23. 'ts-jest': {
  24. babelConfig: {
  25. presets: [
  26. [
  27. '@babel/preset-env',
  28. {
  29. targets: {
  30. node: true
  31. },
  32. modules: 'commonjs'
  33. }
  34. ]
  35. ],
  36. plugins: ['@babel/plugin-syntax-dynamic-import']
  37. }
  38. }
  39. },
  40. transformIgnorePatterns:
  41. [`<rootDir>/node_modules/(?!${esModules})`]
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement