我正在使用一些代码,我需要测试函数抛出的异常类型(是TypeError,ReferenceError等).
我目前的测试框架是AVA,我可以测试它作为第二个参数t.throws方法,就像这里:
it('should throw Error with message \'UNKNOWN ERROR\' when no params were passed', (t) => {
const error = t.throws(() => {
throwError();
}, TypeError);
t.is(error.message, 'UNKNOWN ERROR');
});
Run Code Online (Sandbox Code Playgroud)
我开始将我的测试改写为Jest,但却找不到如何轻松地做到这一点.它甚至可能吗?
I have problems with source maps. Instead of proper ES6 code I'm receiving source maps with babel-transpiled ES5 file. I tried every type of devtool sourcemaps, even with webpack.SourceMapDevToolPlugin.
当我使用eval文件路径看起来不错,但是当我单击它们时,它会转到正确的文件,但是在转换为ES5之后,正确的路径 -在其他源映射类型中,路径看起来像这样:错误的路径
我不知道我还能尝试什么。
common.webpack.js文件:
const webpack = require('webpack');
const argv = require('minimist')(process.argv.slice(2));
const {
root,
removeEmpty,
ifProd,
ifDev,
getEnvConsts,
ifRelease,
} = require('../helpers');
const defaults = require('../defaults');
// Webpack plugins
const CleanPlugin = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const …Run Code Online (Sandbox Code Playgroud)