lundi 23 juillet 2018

Enzyme Installation difficulties

So I've been using create-react-app and wanted to implement testing. So I read and followed the create-react-app repo to install Enzyme. Enzyme intsallation link

I install and run the Smoke Test.

npm test

import React from 'react';
import { shallow } from 'enzyme';
import App from './App';

it('renders without crashing', () => {
  shallow(<App />);
});

and then I get this error in the console.

Determining test suites to run...events.js:167 throw er; // Unhandled 'error' event ^

Error: spawn hg EACCES at Process.ChildProcess._handle.onexit (internal/child_process.js:217:19) at onErrorNT (internal/child_process.js:394:16) at process._tickCallback (internal/process/next_tick.js:174:19) Emitted 'error' event at: at Process.ChildProcess._handle.onexit (internal/child_process.js:223:12) at onErrorNT (internal/child_process.js:394:16) at process._tickCallback (internal/process/next_tick.js:174:19) npm ERR! Test failed. See above for more details.

Here's my package.json:

{
      "name": "jest",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "enzyme": "^3.3.0",
        "enzyme-adapter-react-16": "^1.1.1",
        "react": "^16.4.1",
        "react-dom": "^16.4.1",
        "react-scripts": "1.1.4",
        "react-test-renderer": "^16.4.1"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    }

If I change the "test" script to:

"test":"jest",

then run

npm test

I get this error afterwards:Unexpected Token

Please help, I've been at it for hours.

Aucun commentaire:

Enregistrer un commentaire