标签: wallaby.js

推荐 Wallaby.js 替代品?

我正在尝试寻找 Wallaby.js 的替代品。我希望“即时”查看测试结果(在 VScode 或 Webstorm 中),最好是免费或至少更便宜的替代方案。搜索谷歌并没有找到任何。有什么建议吗?

javascript unit-testing wallaby.js

14
推荐指数
0
解决办法
655
查看次数

使用小袋鼠测试时出现意外的保留字错误

在我编写测试用例的测试文件中,我导入了一个打字稿文件,如下所示:

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)

typescript wallaby.js

7
推荐指数
1
解决办法
577
查看次数

小袋鼠和原型错误

问题是原型未定义,尽管在节点控制台中编写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)

javascript node.js typescript wallaby.js angular

7
推荐指数
1
解决办法
184
查看次数

ReferenceError:找不到变量:在src/app/home/home.component.spec.ts上映射:4 Angular 2

我似乎设置了可错的故障.

错误:

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)

wallaby.js

6
推荐指数
1
解决办法
360
查看次数

如何使用 jest 测试 electro ipc 事件?

我正在对我正在构建的电子应用程序进行一些测试。我遇到了下面的错误。我是开玩笑的新手,所以我想这是由于设置不正确造成的。知道我哪里出错了吗?

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)

unit-testing node.js jestjs electron wallaby.js

3
推荐指数
1
解决办法
3816
查看次数