Package Exports
- @testdeck/jest
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@testdeck/jest) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
testdeck-jest
Jest testing with style - the OOP way
import { suite, test } from "testdeck-jest";
@suite
class Hello {
@test
world() {
// place your assertions here
}
}
Documentation Licensing
All documentation is licenced under the CC BY-NC 4.0 license.
You need legal consent by all direct maintainers of the project in order to use (parts of) the documentation for any commercial purposes.
Features
- Object Oriented Interface
- Parameterised Tests
- Dependency Injection Support
Installation
Just run
npm install --save-dev testdeck-jest
npm install --save-dev @types/jest
and you are ready to go.
And, depending on your project, you will also have to install the type declarations for node.
npm install --save-dev @types/node
Usage
Classes can be annotated with @suite
to make them test suites, similarly so, individual methods of test suites can
be annotated using @test
. And, by using inheritance, one can build complex test suites and reuse existing
code.
The test interface also supports jest's built-in BDD and TDD interfaces such as describe
and it
.
And you can mix both the OOP style and the declarative style, and you can even create nested suites by using a mixture of both styles.
import { suite, test } from "testdeck-jest";
@suite
class Suite {
@test
method() {}
}
// mixed operations
describe("outer", () => {
it("one", () => {});
@suite
class Inner {
@test
method() {}
}
});
// abstract suites
abstract class TestBase {
@test
commonTest() {
}
}
@suite
class ConcreteTest extends TestBase {
@test
specificTest() {
}
}
Please keep in mind, that when the tests are run, a new instance of the test suite will be instantiated before each test method is executed.
Watcher
You can use the standard jest watcher script.
Further Reading
- API
- Object Oriented Testing
- Extending Test Behaviour
- Using the Watcher
- Set up testdeck-jest
- IDE Integration