在Rails应用中实现Jest语法错误:意外的标识符config / webpack / test.js失败

时间:2018-09-25 15:12:53

标签: ruby-on-rails jestjs enzyme webpacker

我正在将测试从我的rails / react应用程序中的Karma切换到Jest。通过遵循教程here,我解决了一些错误,并通过了一项PASS虚拟测试> cat sum_num.txt 26/06/2018 12890765 www.example.com 986.00 31/08/2018 17464946 www.other.com 7627.00 1/05/2018 65472345 www.example.com 14.00 > perl -ne ' { s/(.+)\s+(.+)$/\2/osmg;$x+=$_;print} END { print "Sum=$x\n"} ' sum_num.txt 986.00 7627.00 14.00 Sum=8627 >

exportApplicationGlobal: true

这是终端输出:

spec/javascript/sum.test.js

但是我的test('1 + 1 equals 2', () => { expect(1 + 1).toBe(2); }) 以及我之前为Karma创建并后来适应Jest的其他测试都失败了。感觉我没有正确设置webpacker。 这是我的 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

提前谢谢

0 个答案:

没有答案