helpers.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.enhanceUnexpectedTokenMessage = undefined;
  6. var _chalk;
  7. function _load_chalk() {
  8. return (_chalk = _interopRequireDefault(require('chalk')));
  9. }
  10. function _interopRequireDefault(obj) {
  11. return obj && obj.__esModule ? obj : {default: obj};
  12. }
  13. const DOT = ' \u2022 ';
  14. const enhanceUnexpectedTokenMessage = (exports.enhanceUnexpectedTokenMessage = e => {
  15. e.stack =
  16. `${(_chalk || _load_chalk()).default.bold.red(
  17. 'Jest encountered an unexpected token'
  18. )}
  19. This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
  20. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
  21. Here's what you can do:
  22. ${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${(
  23. _chalk || _load_chalk()
  24. ).default.bold('"transformIgnorePatterns"')} in your config.
  25. ${DOT}If you need a custom transformation specify a ${(
  26. _chalk || _load_chalk()
  27. ).default.bold('"transform"')} option in your config.
  28. ${DOT}If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the ${(
  29. _chalk || _load_chalk()
  30. ).default.bold('"moduleNameMapper"')} config option.
  31. You'll find more details and examples of these config options in the docs:
  32. ${(_chalk || _load_chalk()).default.cyan(
  33. 'https://jestjs.io/docs/en/configuration.html'
  34. )}
  35. ${(_chalk || _load_chalk()).default.bold.red('Details:')}
  36. ` + e.stack;
  37. return e;
  38. });