반응 애플 리케이션을 구성하는 데 nwb를 사용하고 있습니다. chai
및 enzyme
을 사용하여 테스트 환경을 설정합니다. 에 index.spec.js
을 정의한 후 nwb test
를 실행했을 때 오류가 발생하는webpack 및 karma nwb와 작동하도록 phantomjs 구성
const karmaChaiPlugins = require('karma-chai-plugins');
module.exports = {
type: 'react-component',
npm: {
esModules: true,
umd: {
global: 'ReactMg',
externals: {
react: 'React',
},
},
},
karma: {
testContext: 'tests.webpack.js',
plugins: [
karmaChaiPlugins,
],
frameworks: ['mocha', 'chai', 'chai-as-promised'],
},
webpack: {
compat: {
enzyme: true,
sinon: true,
},
},
};
:
import chai from 'chai';
import chaiEnzyme from 'chai-enzyme';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';
chai.use(chaiEnzyme());
chai.use(chaiAsPromised);
chai.use(sinonChai);
const context = require.context('./src', true, /\.spec\.js/);
context.keys.forEach(context);
나는 또한 nwb.config.js
의 카르마 설정을 수정 : 나는 다음과 같은 변화가 이러한 목표를 달성하기 위해 만들었습니다, 나는 tests.webpack.js
파일을 만든 src
: UNDEFINE :
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
TypeError: undefined is not a function (evaluating 'context.keys.forEach(context)')
at tests.webpack.js:73
PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 0 ERROR (0.375 secs/0 secs)
Karma exit code was 1
, 잘 모릅니다 어떻게 내가 그것을 놓쳤는 지. 감사합니다 @ maksimr – vamsiampolu