3
所以我運行一個非常基本的玩笑測試,測試如果我的路線之一返回200玩笑測試失敗
import request from 'supertest';
import app from './../app';
describe('GET /',() => {
it('should render properly', async() => {
await request(app).get('/api/testing').expect(200);
});
});
這是正常使用,然後我配置了webpack-hot-middleware,並且它似乎在第2行打破了我導入應用程序的地方。
TypeError: setInterval(...).unref is not a function
at createEventStream (node_modules/webpack-hot-middleware/middleware.js:50:17)
at webpackHotMiddleware (node_modules/webpack-hot-middleware/middleware.js:12:21)
at Object.<anonymous> (server/app.js:62:73)
at Object.<anonymous> (server/test/routes.test.js:2:38)
如果我從我的app.js中刪除下面的代碼,測試都運行良好。
app.use(middleware);
app.use(webpackHotMiddleware(compiler));
app.get('*', (req, res) => {
res.write(middleware.fileSystem.readFileSync(path.join(__dirname, '../dist/index.html')));
res.end();
});
有沒有人配置Jest for webpack-hot-middleware?我有點失落,因爲我覺得我已經嘗試了一切。