Skip to content

What is the correct way to initialise the validation plugin during unit tests? #377

Closed
@stevies

Description

@stevies

Question.

I am using aurelia with webpack. Current versions of everything.

What is the correct way to initialise the validation plugin during unit tests?

I have tried something like this - setup.js:

import 'aurelia-polyfills';
import {initialize} from 'aurelia-pal-browser';
import {StageComponent} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrapper-webpack';

initialize();

let component;

beforeEach(function () {
  component = StageComponent
    .withResources();
  component.bootstrap(aurelia => {
    aurelia.use
      .plugin('aurelia-validation');
  });
});

afterEach(function () {

});

But that does not seem to work (maybe I have missed something important).

When I start my tests, I get error:

START:
28 10 2016 09:25:26.895:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
28 10 2016 09:25:26.896:INFO [launcher]: Launching browser Chrome with unlimited concurrency
28 10 2016 09:25:26.931:INFO [launcher]: Starting browser Chrome
28 10 2016 09:25:28.441:INFO [Chromium 53.0.2785 (Ubuntu 0.0.0)]: Connected on socket /#KzQZITDoJTIuxFbZAAAA with id 93068450
Chromium 53.0.2785 (Ubuntu 0.0.0) ERROR
  Uncaught Error: Did you forget to add ".plugin('aurelia-validation)" to your main.js?
  at webpack:///~/aurelia-validation/dist/commonjs/implementation/validation-rules.js:350:0 <- spec-bundle.js:16402
Chromium 53.0.2785 (Ubuntu 0.0.0) ERROR
  Uncaught Error: Did you forget to add ".plugin('aurelia-validation)" to your main.js?
  at webpack:///~/aurelia-validation/dist/commonjs/implementation/validation-rules.js:350:0 <- spec-bundle.js:16402

This may be related to issues with aurelia-bootstrapper-webpack - there are defects raised there.

But I am wondering if there is any other way to make sure the plugin is initialised. This is preventing all unit testing taking place in my app.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions