Error during loading: Uncaught ReferenceError: module is not defined in http://localhost:9876/_karma_webpack_/scripts.js line 1
Error during loading: Uncaught ReferenceError: module is not defined in http://localhost:9876/_karma_webpack_/scripts.js line 1
Error image
我正在使用 angular 进行 jasmine karma 单元测试,但收到此错误。请帮助
这是我的karma.conf.js
业力。 conf.js
// Karma configuration file, see link for more information //<br> https://karma-runner.github.io/1.0/config/configuration-file.html<br>
module.exports = function (config) { config.set({<br>
basePath: '',<br>
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [<br>
require('karma-jasmine'),<br>
require('karma-chrome-launcher'),<br>
require('karma-jasmine-html-reporter'),<br>
require('karma-coverage-istanbul-reporter'),<br>
require('@angular-devkit/build-angular/plugins/karma')<br>
],<br>
client: {<br>
clearContext: false // leave Jasmine Spec Runner output visible in browser<br>
},
coverageIstanbulReporter: {<br>
dir: require('path').join(__dirname, './coverage/Certification-Portal'),<br>
reports: ['html', 'lcovonly', 'text-summary'],<br>
fixWebpackSourcePaths: true<br>
},<br>
reporters: ['progress', 'kjhtml'],<br>
port: 9876,
colors: true,<br>
logLevel: config.LOG_INFO,<br>
autoWatch: true,<br>
browsers: ['Chrome'],<br>
singleRun: false,<br>
restartOnFileChange: true }); };<br>
找到引发此错误的文件,然后转到同一文件的 index.js 并删除其中的 'module.'。它会在您测试应用程序时起作用。请在完成单元测试后添加它。
注意:您只能在节点模块中找到该文件。确切的文件名请参考控制台错误消息,它会向您显示导致文件出错的路径。
Error image
我正在使用 angular 进行 jasmine karma 单元测试,但收到此错误。请帮助
这是我的karma.conf.js
业力。 conf.js
// Karma configuration file, see link for more information //<br> https://karma-runner.github.io/1.0/config/configuration-file.html<br>
module.exports = function (config) { config.set({<br>
basePath: '',<br>
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [<br>
require('karma-jasmine'),<br>
require('karma-chrome-launcher'),<br>
require('karma-jasmine-html-reporter'),<br>
require('karma-coverage-istanbul-reporter'),<br>
require('@angular-devkit/build-angular/plugins/karma')<br>
],<br>
client: {<br>
clearContext: false // leave Jasmine Spec Runner output visible in browser<br>
},
coverageIstanbulReporter: {<br>
dir: require('path').join(__dirname, './coverage/Certification-Portal'),<br>
reports: ['html', 'lcovonly', 'text-summary'],<br>
fixWebpackSourcePaths: true<br>
},<br>
reporters: ['progress', 'kjhtml'],<br>
port: 9876,
colors: true,<br>
logLevel: config.LOG_INFO,<br>
autoWatch: true,<br>
browsers: ['Chrome'],<br>
singleRun: false,<br>
restartOnFileChange: true }); };<br>
找到引发此错误的文件,然后转到同一文件的 index.js 并删除其中的 'module.'。它会在您测试应用程序时起作用。请在完成单元测试后添加它。
注意:您只能在节点模块中找到该文件。确切的文件名请参考控制台错误消息,它会向您显示导致文件出错的路径。