Aurelia-Testing with Jasmine/Karma Fails


#1

We have attempted to get the example running as described by: https://aurelia.io/docs/testing/components#getting-started.

However, the code inside the component.create(bootstrap).then() block does not execute. As a consequence of the component creation failing, component.dispose(); also fails, since it cannot dispose of a component that has not been created.

Using Chrome, the console displays ‘Uncaught (in promise) Error: Unable to find module with ID: aurelia-pal-browser’.

We are unable to resolve this. The platform is Windows 10, and we are using aurelia-testing (1.0.0-beta.4.0.0) and aurelia-pal-browser (1.8.0).

Any help would be appreciated.


#2

So the actual code snippet is this one:

import {StageComponent} from ‘aurelia-testing’;
import {bootstrap} from ‘aurelia-bootstrapper’;

describe('MyComponent', () => {
  let component;

  beforeEach(() => {
    component = StageComponent
      .withResources('my-component')
      .inView('<my-component first-name.bind="firstName"></my-component>')
      .boundTo({ firstName: 'Bob' });
  });

  it('should render first name', done => {
    component.create(bootstrap).then(() => {
      const nameElement = document.querySelector('.firstName');
      expect(nameElement.innerHTML).toBe('Bob');
      done();
    }).catch(e => { console.log(e.toString()) });
  });

  afterEach(() => {
    component.dispose();
  });
});

Interestingly, there is a reference to the PAL browser inside the webpack. So why can’t the framework find it?


#3

Try it with:

 component = StageComponent
      .withResources(PLATFORM.moduleName('my-component'))

#4

There’s no functional difference with that change in. Still get the same error.

I don’t believe it is the test example code. I think the framework has an issue for some reason. Here’s the error and last part of the stack trace (i.e. framework code issuing the error).

Capture


#5

And in our webpack, app.js, here is the only reference I can find to the PAL browser.

Any thoughts? Does that look correct?