我正在尝试寻找 Wallaby.js 的替代品。我希望“即时”查看测试结果(在 VScode 或 Webstorm 中),最好是免费或至少更便宜的替代方案。搜索谷歌并没有找到任何。有什么建议吗?
在我编写测试用例的测试文件中,我导入了一个打字稿文件,如下所示:
import {rootReducer} from "../src/reducers/rootReducer";
Run Code Online (Sandbox Code Playgroud)
在rootReducer.ts中我导入了另一个打字稿文件,如下所示:
import taskReducer from "./taskReducer.ts";
Run Code Online (Sandbox Code Playgroud)
然后它显示错误:
SyntaxError: Unexpected reserved word
at src/reducers/rootReducer.ts:7
Run Code Online (Sandbox Code Playgroud)
rootReducer.ts和taskReducer.ts都位于文件夹/ src/reducers下
如果从import语句中删除".ts",但在浏览器中抛出错误,则没有失败的测试.该应用程序将无法运行
小袋鼠配置如下:
module.exports = function (wallaby) {
return {
files: [
'src/*.ts',
'src/**/*.ts'
],
tests: [
'test/*Test.ts'
],
testFramework: "mocha",
env: {
type: 'node'
},
compilers: {
'**/*.ts': wallaby.compilers.typeScript({
/* 1 for CommonJs*/
module: 1
})
}
}
};
Run Code Online (Sandbox Code Playgroud) 问题是原型未定义,尽管在节点控制台中编写http.IncomingMessage.prototype确实将对象作为输出.有任何想法吗 ?
var req = Object.create(http.IncomingMessage.prototype)
Uncaught TypeError: Cannot read property 'prototype' of undefined
at http://localhost:62625/____wallaby-bundle.js?1501265946287&wallabyFileId=bundle:219253
Run Code Online (Sandbox Code Playgroud) 我似乎设置了可错的故障.
错误:
ReferenceError: Can't find variable: Map
at src/app/home/home.component.spec.ts:4
ReferenceError: Can't find variable: Map
at http://localhost:63247/__modules/27.js?1483285680907:80
Run Code Online (Sandbox Code Playgroud)
我这样设置我的js
文件:
var wallabyWebpack = require('wallaby-webpack');
var webpackPostprocessor = wallabyWebpack({
entryPatterns: [
'src/wallabyTest.js',
'src/**/*spec.js'
],
module: {
loaders: [
{test: /\.css$/, loader: 'raw-loader'},
{test: /\.html$/, loader: 'raw-loader'},
{test: /\.js$/, loader: 'angular2-template-loader', exclude: /node_modules/},
{test: /\.json$/, loader: 'json-loader'},
{test: /\.styl$/, loaders: ['raw-loader', 'stylus-loader']},
{test: /\.less$/, loaders: ['raw-loader', 'less-loader']},
{test: /\.scss$|\.sass$/, loaders: ['raw-loader', 'sass-loader']},
{test: /\.(jpg|png)$/, loader: 'url-loader?limit=128000'}
]
}
});
var compilerOptions = require('./src/tsconfig.json').compilerOptions; …
Run Code Online (Sandbox Code Playgroud) 我正在对我正在构建的电子应用程序进行一些测试。我遇到了下面的错误。我是开玩笑的新手,所以我想这是由于设置不正确造成的。知道我哪里出错了吗?
Error: Cannot find module 'ipcMain' from 'ipcMainEvents.spec.js'
//myEvents.ts
import { ipcMain } from 'electron'
export class IpcMainEvents {
constructor() {
ipcMain.on('openPlaywright', this.openPlaywright)
ipcMain.on('openPreviewBrowser', this.openPlaywright)
}
openPlaywright(event, arg) {
console.log('openPlaywright')
}
openPreviewBrowser(event, arg) {
console.log('openPreviewBrowser')
}
}
//myEvents.spec.ts
import {IpcMainEvents} from './ipcMainEvents'
import {ipcMain} from 'electron'
jest.mock('ipcMain')
describe('Should test the ipcMain events', () => {
let component;
let addSpy
beforeEach(()=>{
component = new IpcMainEvents()
})
it('should attach the eventListeners', () => {
expect(component.ipcMain.on.calls.all()[0].args[0]).toEqual('openPlaywright'); //<----Errors here
expect(component.ipcMain.on.calls.all()[1].args[0]).toEqual('openPreviewBrowser');
expect(component.ipcMain.on.calls.count()).toEqual(2);
});
});
Run Code Online (Sandbox Code Playgroud) wallaby.js ×5
javascript ×2
node.js ×2
typescript ×2
unit-testing ×2
angular ×1
electron ×1
jestjs ×1