aurelia / testing

Simplifies the testing of UI components by providing an elegant, fluent interface for arranging test setups along with a number of runtime debug/test helpers.
MIT License
40 stars 27 forks source link

Type definition of bootstrap is inconsistent with aurelia-bootstrapper #41

Closed michaelbull closed 7 years ago

michaelbull commented 7 years ago

I'm submitting a bug report

1.0.0-beta.2.0.0

Please tell us about your environment:

Current behavior:

Argument of type '(configure: Function) => Promise<void>' is not assignable to parameter of type '(aurelia: Aurelia) => Promise<void>'.
  Types of parameters 'configure' and 'aurelia' are incompatible.
    Type 'Aurelia' is not assignable to type 'Function'.
      Property 'apply' is missing in type 'Aurelia'.

Expected/desired behavior:

The bootstrap function has the the following method signature: bootstrap(configure: Function): Promise<void>, but the create method in aurelia-testing expects a bootstrap method of type (aurelia: Aurelia) => Promise<void>.

This creates a type exception as pasted above.

This can be reproduced by following the official documentation (in TypeScript) for testing a custom element.

The type definitions should be corrected to not produce this error every time tests are ran.

EisenbergEffect commented 7 years ago

This is TS issue I think, since we need the Aurelia type but can't import that library into the bootstrapper's code. We'll need to investigate how best to solve this since TS doesn't have any notion of Type info without code import...at least not that I'm aware of.

michaelbull commented 7 years ago

A current workaround to prevent the error from being printed in the console is to cast bootstrap to any, e.g. component.create(bootstrap as any).then(() => {.

This then leads to the following error, but it's only printed once and not for every test using the bootstrap function:

WARNING in ./~/aurelia-bootstrapper/dist/commonjs/aurelia-bootstrapper.js
Critical dependencies:
68:13-20 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/aurelia-bootstrapper/dist/commonjs/aurelia-bootstrapper.js 68:13-20
EisenbergEffect commented 7 years ago

Fixed: https://github.com/aurelia/testing/pull/52