Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Fix issue where ES6 won't compile with Jest and Neutrino v8 (#640)
Browse files Browse the repository at this point in the history
* Fix issue where ES6 won't compile with Jest and Neutrino v8

* Use neutrino.options.extensions to cover additional extensions
  • Loading branch information
helfi92 authored and Tim Kelty committed Dec 21, 2017
1 parent d229f90 commit 91541a8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ function getFinalPath(path) {
}

function normalizeJestOptions(opts, neutrino, usingBabel) {
const mediaNames = `\\.(${mediaExtensions.join('|')})`;
const styleNames = `\\.(${['css', 'less', 'sass', 'scss'].join('|')})`;
const jsNames = neutrino.regexFromExtensions(['js', 'jsx']);
const mediaNames = `\\.(${mediaExtensions.join('|')})$`;
const styleNames = `\\.(${['css', 'less', 'sass', 'scss'].join('|')})$`;

// neutrino.options.extensions should be used instead of neutrino.regexFromExtensions()
// because transformNames is used as a property name where a Regex object will cause issues.
// e.g., https://github.com/mozilla-neutrino/neutrino-dev/issues/638.
const transformNames = `\\.(${neutrino.options.extensions.join('|')})$`;
const aliases = neutrino.config.resolve.alias.entries() || {};
const moduleNames = Object
.keys(aliases)
Expand Down Expand Up @@ -58,7 +62,7 @@ function normalizeJestOptions(opts, neutrino, usingBabel) {
coveragePathIgnorePatterns: [neutrino.options.node_modules],
collectCoverageFrom: [join(basename(neutrino.options.source), '**/*.js')],
testRegex,
transform: { [jsNames]: require.resolve('./transformer') },
transform: { [transformNames]: require.resolve('./transformer') },
globals: {
BABEL_OPTIONS: usingBabel
? omit(['cacheDirectory'], neutrino.config.module.rule('compile').use('babel').get('options'))
Expand Down

0 comments on commit 91541a8

Please sign in to comment.