gpt4 book ai didi

node.js - Karma 出现 ReferenceError : Can't find variable: module on the karma config file itself 错误

转载 作者:搜寻专家 更新时间:2023-11-01 00:01:59 25 4
gpt4 key购买 nike

我在 karma 配置文件中有 angular 和 angular-mocks 文件,但在我到达那里之前它就出错了..

所有关于此引用错误的在线文档都说我没有安装 angular-mocks,但我很确定这是规范文件中模块变量的错误,而不是初始 karma 配置。

这是我的配置文件。

module.exports = function ( karma ) {

karma 集({ /** * 从哪里找文件,从这个文件所在的位置开始。 */ basePath: '../',

/**
* This is the list of file patterns to load into the browser during testing.
*/
files: [
'vendor/angular/angular.js',
'vendor/angular-mocks/angular-mocks.js',
'vendor/angular-bootstrap-jbruni/ui-bootstrap-tpls.min.js',
'vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js',
'vendor/angular-ui-router/release/angular-ui-router.js',
'vendor/lodash/dist/lodash.min.js',
'vendor/angular-breadcrumb/angular-breadcrumb.js',
'vendor/restangular/dist/restangular.js',
'build/templates-app.js',
'build/templates-common.js',

'src/**/*.js',
'src/**/*.coffee',
],
exclude: [
'src/assets/**/*.js'
],
frameworks: [ 'jasmine' ],
plugins: [ 'karma-jasmine', 'karma-firefox-launcher', 'karma-coffee-preprocessor' ],
preprocessors: {
'**/*.coffee': 'coffee',
},

/**
* How to report, by default.
*/
reporters: 'dots',

/**
* On which port should the browser connect, on which port is the test runner
* operating, and what is the URL path for the browser to use.
*/
port: 9018,
runnerPort: 9100,
urlRoot: '/',

/**
* Disable file watching by default.
*/
autoWatch: false,

/**
* The list of browsers to launch to test on. This includes only "Firefox" by
* default, but other browser names include:
* Chrome, ChromeCanary, Firefox, Opera, Safari, PhantomJS
*
* Note that you can also use the executable name of the browser, like "chromium"
* or "firefox", but that these vary based on your operating system.
*
* You may also leave this blank and manually navigate your browser to
* http://localhost:9018/ when you're running tests. The window/tab can be left
* open and the tests will automatically occur there during the build. This has
* the aesthetic advantage of not launching a browser every time you save.
*/
browsers: [
'Firefox'
]

});};

最佳答案

我刚刚遇到了类似的问题。

ReferenceError:找不到变量:模块

在 karma 配置文件的“files:”部分包含“angular-mocks.js”的路径后,它能够找到模块。

// list of files / patterns to load in the browser
files: [
'../js/angular.min.js',
'../js/myutils-service.js',
'./angular-mocks.js',
'./my-service.js'
],

关于node.js - Karma 出现 ReferenceError : Can't find variable: module on the karma config file itself 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25330578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com