test environment for exercising the Aurelia.d.ts
TypeScript definition file and related TypeScript tests
This TypeScript test project is part of the Aurelia platform. Karma/Jasmine testing is configured.
To keep up to date on Aurelia, please visit and subscribe to the official blog. If you have questions, we invite you to join us on our Gitter Channel.
To run the tests, follow these steps.
- Ensure that NodeJS is installed. This provides the platform on which the build tooling runs.
- From the project folder, execute the following command:
npm install
- Ensure that jspm is installed. If you need to install it, use the following command:
npm install -g jspm
- Install the client-side dependencies with jspm:
jspm install
- To view the tests in Visual Studio, open the solution with Visual Studio 2003, Update 4:
To run the unit tests, first ensure that you have followed the steps above in order to install all dependencies and successfully build the library. Once you have done that, proceed with these additional steps:
- Ensure that the Karma CLI is installed. If you need to install it, use the following command:
npm install -g karma-cli
- You can now run the tests with this command:
karma start
You can edit the tests in Visual Studio. When you save, karma is watching the test files to detect changes and will re-run the tests. You will see test results (successes & failures) in the shell.
By default, the latest release of the dependency repos (github:aurelia/dependency-injection and github:aurelia/metadata) are used. Follow these steps to run this project against the latest on master.
-
Download to a folder named
aurelia
and build the repos (follow the repo instructions) -
Update the dependencies in the
dependency-injection
This points the dependency-injection
at the local metadata
instead of the released version.
gulp update-own-deps
- Update the dependencies in
au-vs-ts-test
This points the au-vs-ts-test
at the local dependency-injection
and metadata
instead of the released versions.
gulp update-own-deps
- You can now run the tests with this command:
karma start
We'd love for you to contribute to our source code and to make this project even better than it is today! If this interests you, please begin by reading our contributing guidelines. The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also sign our CLA before we can accepts a Pull Request from you. More information on the process is including in the contributor's guide.
There appears to be some interesting behavior with derived classes.
When setting a DI attribute of a base class in TypeScript code, the derived class will not get the attribute (and therefore DI derived class behavior will not be as expected when the attribute controls desired DI behavior) if the attribute is set AFTER the derived class is defined.
The tests around 15 and 15A in the repo both pass.
// 15 -----------------
class LoggerBase15 { static annotations = [] }
LoggerBase15.annotations = [new audi.Transient()];
class Logger15 extends LoggerBase15 { }
class App15One {
static inject() { return [Logger15]; }
constructor(public logger: Logger15) { }
}
class App15Two {
static inject() { return [Logger15]; }
constructor(public logger: Logger15) { }
}
// 15A -----------------
class LoggerBase15A { static annotations = [] }
class Logger15A extends LoggerBase15A { }
LoggerBase15A.annotations = [new audi.Transient()];
class App15AOne {
static inject() { return [Logger15A]; }
constructor(public logger: Logger15A) { }
}
class App15ATwo {
static inject() { return [Logger15A]; }
constructor(public logger: Logger15A) { }
}
it("uses base annotations property (ES5, AtScript, TypeScript, CoffeeScript) when derived does not specify", function () {
var container = new audi.Container();
var app1 = container.get<App15One>(App15One);
var app2 = container.get<App15Two>(App15Two);
expect(app1.logger).not.toBe(app2.logger);
});
it("uses base annotations property (ES5, AtScript, TypeScript, CoffeeScript) when derived does not specify", function () {
var container = new audi.Container();
var app1 = container.get<App15AOne>(App15AOne);
var app2 = container.get<App15ATwo>(App15ATwo);
expect(app1.logger).toBe(app2.logger);
});