所以我在尝试使用 jasmine 和 webpack 运行业力时遇到了这个错误:
Uncaught ReferenceError: jasmineRequire is not defined
at node_modules/karma-jasmine/lib/boot.js:116
我认为这是我的项目,所以我决定创建一个新项目,以下是它的配置。
我对这个配置有同样的问题。有人有想法吗?
对于 webpack:
const path = require("path");
module.exports = {
entry: './src/source1.js',
output: {
path: path.resolve("./dist")
}
}
对于业力:
const webpackConfig = require("./webpack.config");
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
webpack: webpackConfig,
files: [
'test/t1.js'
],
exclude: [
],
preprocessors: {
"**/*.js": ["webpack"]
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
我有一个像这样的 test/t1.js 文件:
// import { add } from "../src/source1";
function add(x, y) {
return x + y;
}
describe("source1", () => {
describe("add", () => {
it("adds 41 + 1", () => {
expect(add(41, 1)).toBe(42);
});
});
});
这是我的 package.json 文件:
{
"name": "projects",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jasmine-core": "^2.6.2",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-jasmine": "^1.1.0",
"karma-webpack": "^2.0.3",
"webpack": "^2.5.1"
}
}