Unit tests with Webpack

Is there any possiblity to run async unit tests with Webpack?
All the time I’m getting webpack_require :frowning:
And I can’t fix it.
We are using webpack in whole project and everything works, but not in unit tests.

It’s hard to determine from the description as webpack_require seems weird to be thrown from unit tests. Could you create and share some sample project with aurelia, webpack and sample test replicating your issue? I have a project with aurelia+webpack and unit tests testing some async call - however, I catch the promise and handle it with .then( x=> {... done()}) .catch( e=>{ faile(e);done();});.

Tomas, please check my last comment here:

Hi @jkowalski,

Sure, it is possible, we’re using async unit tests with webpack.
The testing framework we’re using is jest, and the syntax looks like this:

it('my async test', (done) => {
            myAsyncMethod().then((result) => {

And the jest-setup file looks like this:

import { Options } from 'aurelia-loader-nodejs';
import { globalize } from 'aurelia-pal-nodejs';
import 'aurelia-polyfills';
import * as path from 'path';

Options.relativeToDir = path.join(__dirname, 'unit');


Still nothing :confused:

Our jest-pretest.js looks like this:

import 'aurelia-polyfills';
import 'aurelia-loader-webpack';
import {initialize} from 'aurelia-pal-browser';
import 'jest';

And jest-preprocess.js:

const babelOptions = {
    presets: [
                "targets": {
                    "node": "current"

module.exports = require("babel-jest").createTransformer(babelOptions);

Tests works, but not with webpack (e.g. testing promises) :confused: