Реализация приложения Jest in Rails SyntaxError: Неожиданный идентификатор config / webpack / test.js FAIL - PullRequest
0 голосов
/ 25 сентября 2018

Я переключаю свои тесты с Кармы в моем приложении rails / реагировать на Jest.Следуя инструкции здесь Я получил несколько ошибок, которые я решил, и проверил один фиктивный тест PASS spec/javascript/sum.test.js

test('1 + 1 equals 2', () => {
  expect(1 + 1).toBe(2);
})

Вот вывод терминала:

 PASS  spec/javascript/sum.test.js
 FAIL  spec/features/DeveloperShowContainer.test.js
  ● Test suite failed to run

/Users/arch/LaunchAcademy/challenges/devs_for_non_profit/spec/features/DeveloperShowContainer.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import DeveloperShowContainer from '../../app/javascript/containers/DeveloperShowContainer';
                                                                                                ^^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier

  at new Script (vm.js:74:7)
      at Generator.next (<anonymous>)
      at new Promise (<anonymous>)

FAIL  config/webpack/test.js
  ● Test suite failed to run

Your test suite must contain at least one test.

  at node_modules/jest-cli/build/test_scheduler.js:95:22
      at Generator.next (<anonymous>)
      at new Promise (<anonymous>)

Но мои config/webpack/test.js провалились так же, как и другие тесты, которые я создал ранее для Кармы и позже адаптировал для Джеста.Такое ощущение, что я неправильно настроил webpacker.Вот мой package.json

 {
  "name": "devs_for_non_profit",
  "private": true,
  "engines": {
  "node": ">=6.0.0",
  "yarn": ">=0.25.2"
},
  "dependencies": {
  "@rails/webpacker": "3.5",
  "babel-preset-react": "~6.24.1",
  "prop-types": "~15.6.0",
  "react": "~15.4.2",
  "react-dom": "~15.4.2",
  "react-redux": "^5.0.7",
  "react-router": "3.2.0",
  "react-select-2": "^2.0.11",
  "redux": "^4.0.0",
  "redux-mock-store": "^1.5.3",
  "redux-thunk": "^2.3.0"
},
  "devDependencies": {
  "babel-jest": "^23.4.0",
  "jest-cli": "^21.2.1",
  "enzyme": "~2.9.1",
  "enzyme-adapter-react-15.4": "^1.0.6",
  "enzyme-adapter-react-16": "^1.5.0",
  "fetch-mock": "5",
  "isomorphic-fetch": "^2.2.1",
  "jasmine-ajax": "3.2.0",
  "jasmine-core": "~2.4.1",
  "jasmine-enzyme": "~3.4.0",
  "jest": "^23.6.0",
  "jest-fetch-mock": "^1.6.5",
  "karma": "~0.13.22",
  "karma-coverage": "0.5.5",
  "karma-jasmine": "~0.3.8",
  "karma-phantomjs-launcher": "~1.0.4",
  "karma-sourcemap-loader": "0.3.7",
  "karma-spec-reporter": "0.0.26",
  "karma-webpack": "2.0.1",
  "phantomjs-prebuilt": "~2.1.14",
  "react-addons-test-utils": "~15.6.2",
  "react-test-renderer": "^16.5.2",
  "webpack-cli": "^2.0.10",
  "webpack-dev-server": "^2.11.1"
},
  "scripts": {
   "start": "./bin/webpack-dev-server",
   "test-watch": "jest --watch",
   "test": "jest"
},
   "jest": {
     "automock": false,
     "roots": [
     "spec/javascript"
     ],
   "moduleDirectories": [
   "node_modules",
   "app/javascript"
  ]
 }
}

Заранее спасибо

...