So I'm running a very basic Jest test to test if one of my routes returns a 200.
import request from 'supertest';
import app from './../app';
describe('GET /', () => {
it('should render properly', async () => {
await request(app).get('/api/testing').expect(200);
});
});
This was working perfectly then I configured webpack-hot-middleware and it seems to break at line 2 where I import app.
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)
If I remove the following code from my app.js the tests all run fine.
app.use(middleware);
app.use(webpackHotMiddleware(compiler));
app.get('*', (req, res) => {
res.write(middleware.fileSystem.readFileSync(path.join(__dirname, '../dist/index.html')));
res.end();
});
Has anyone configured Jest for webpack-hot-middleware? I'm kind of lost because I feel like I've tried everything.
You must set testEnvironment Jest config option to node
. unref()
exists in Node.js only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With