Javascript 摩卡罐';在导入的代码中找不到模块
我有一个Phoenix应用程序,正在尝试为javascript单元测试连接Mocha。我想测试模块'2',它导入模块'1',但我不知道如何配置Mocha来找到模块1 以下是测试代码: web/static/js/one.js web/static/js/two.js >test/js/two_test.js 这是我运行Javascript 摩卡罐';在导入的代码中找不到模块,javascript,node.js,phoenix-framework,brunch,es6-modules,Javascript,Node.js,Phoenix Framework,Brunch,Es6 Modules,我有一个Phoenix应用程序,正在尝试为javascript单元测试连接Mocha。我想测试模块'2',它导入模块'1',但我不知道如何配置Mocha来找到模块1 以下是测试代码: web/static/js/one.js web/static/js/two.js >test/js/two_test.js 这是我运行npm测试时的输出 home:~/elixir/optitrue$ npm test > @ test /home/jon/elixir/optitrue > moc
npm测试时的输出
home:~/elixir/optitrue$ npm test
> @ test /home/jon/elixir/optitrue
> mocha --compilers js:babel-register test/js/**/*.js
module.js:457
throw err;
^
Error: Cannot find module 'web/static/js/one'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (two.js:1:1)
at Module._compile (module.js:556:32)
at loader (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:148:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:158:7)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (two_test.js:2:1)
at Module._compile (module.js:556:32)
at loader (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:148:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/jon/elixir/optitrue/node_modules/babel-register/lib/node.js:158:7)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at /home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/home/jon/elixir/optitrue/node_modules/mocha/lib/mocha.js:485:10)
at Object.<anonymous> (/home/jon/elixir/optitrue/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
错误很明显:
Error: Cannot find module 'web/static/js/one'
如果您提供的路径无效,请尝试使用相对路径:
import {One} from "./one";
错误很明显:
Error: Cannot find module 'web/static/js/one'
如果您提供的路径无效,请尝试使用相对路径:
import {One} from "./one";
Error: Cannot find module 'web/static/js/one'
import {One} from "./one";