Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create-react-app config file #1691

Closed
DayBr3ak opened this issue Jun 6, 2018 · 6 comments
Closed

Create-react-app config file #1691

DayBr3ak opened this issue Jun 6, 2018 · 6 comments

Comments

@DayBr3ak
Copy link

DayBr3ak commented Jun 6, 2018

Issue description or question

I can't start wallabyjs on a create-react-app at all. Can you explain what I'm doing wrong

output when I start:

​​​​​0 failing tests, 0 passing​​​​​
​​​​​​​​​​
​​SyntaxError: Invalid regular expression: /[\\\\\]node_modules[\\\\\].+\.(js|jsx|mjs)$/: Unterminated character class​​
​​    at new RegExp (<anonymous>)​​
​​    at shouldTransform (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\ScriptTransformer.js:392:7)​​
​​    at ScriptTransformer._transformAndBuildScript (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\ScriptTransformer.js:271:5)​​
​​    at ScriptTransformer.transform (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\ScriptTransformer.js:316:21)​​
​​    at Runtime._execModule (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\index.js:494:53)​​
​​    at Runtime.requireModule (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\index.js:329:14)​​
​​    at new Runtime (C:\Users\project\node_modules\react-scripts\node_modules\jest-runtime\build\index.js:170:14)​​
​​    at runTest (C:\Users\project\node_modules\react-scripts\node_modules\jest\node_modules\jest-cli\build\runTest.js:78:19)​​
​​    at promise.then (C:\Users\project\node_modules\react-scripts\node_modules\jest\node_modules\jest-cli\build\TestRunner.js:197:14)​​
​​    at <anonymous>​​
​​    at process._tickCallback (internal/process/next_tick.js:118:7)​​

Wallaby.js configuration file

config directly pulled from https://wallabyjs.com/docs/integration/react-jsx.html

module.exports = function(wallaby) {
  // Babel, jest-cli and some other modules may be located under
  // react-scripts/node_modules, so need to let node.js know about it
  var path = require('path')
  process.env.NODE_PATH +=
    path.delimiter +
    path.join(__dirname, 'node_modules') +
    path.delimiter +
    path.join(__dirname, 'node_modules/react-scripts/node_modules')
  require('module').Module._initPaths()

  return {
    files: [
      'src/**/*.+(js|jsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
      '!src/**/*.test.js?(x)'
    ],

    tests: ['src/**/*.test.js?(x)'],

    env: {
      type: 'node',
      runner: 'node'
    },

    compilers: {
      '**/*.js?(x)': wallaby.compilers.babel({
        babel: require('babel-core'),
        presets: ['react-app']
      })
    },

    setup: wallaby => {
      const jestConfig = require('react-scripts/scripts/utils/createJestConfig')(
        p => require.resolve('react-scripts/' + p)
      )
      Object.keys(jestConfig.transform || {}).forEach(
        k => ~k.indexOf('^.+\\.(js|jsx') && void delete jestConfig.transform[k]
      )
      delete jestConfig.testEnvironment
      wallaby.testFramework.configure(jestConfig)
    },

    testFramework: 'jest'
  }
}

Code editor or IDE name and version

Visual Studio Code v1.2.31

OS name and version

Windows 10

create-react-app version 1.5.2

same result on nodejs version 9.10 and 10.3

@ArtemGovorov
Copy link
Member

Hmm, it doesn't look like wallaby specific issue. Does npm test work for you?

@ArtemGovorov
Copy link
Member

Just tried a freshly generated CRA (1.5.2) project on Windows 10 with the config above, and it is working for me.

@ArtemGovorov
Copy link
Member

I'm closing the issue because there's been no activity on it recently. If it is still a valid issue for you, please provide the info requested above.

@ThakurKarthik
Copy link

Test suite failed to run

SyntaxError: Invalid regular expression: /[\\\\\]node_modules[\\\\\].+\.(js|jsx|mjs)$/: Unterminated character class
    at new RegExp (<anonymous>)

  at shouldTransform (node_modules/jest-runtime/build/script_transformer.js:603:9)

@ArtemGovorov
Copy link
Member

@ThakurKarthik Does npm test work for you? If yes, please create a sample repo demonstrating the issue. we are happy to take a look.

@PhilTheAir
Copy link

Similar to this issue: jestjs/jest#6385

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants