Skip to content

Spike: migrate tests to Jest (ts-jest) #3159

@bajtos

Description

@bajtos

Let's try to speed up our dev process and CI builds by migrating to ts-jest.

  1. Jest can run tests in parallel and provides clever watch mode.
  2. ts-jest compiles TypeScript files on the fly, removing the need for costly build.
  3. Jest provides tools for snapshot-based testing, this would be very useful to test CLI code scaffolding TypeScript files and to test code emitting OpenAPI spec.

Known problems to resolve:

  • @loopback/metadata relies on instanceof Function check that does not work under Jest, see fix(metadata): don't rely on instanceof checks #3160
  • @loopback/boot is not able to find & load artifacts from original .ts files
  • Tests using classes defined outside of the scope of test functions fail with ReferenceError, e.g. ReferenceError: Cannot access 'CustomerController' before initialization.
  • Integration with express is broken
  • Repository bindings are not picked up (The key 'repositories.NoteRepository' is not bound to any value in context application)

See the list of skipped files in https://github.com/strongloop/loopback-next/blob/test/jest/jest.config.js for the up-to-date information.

Metadata

Metadata

Assignees

Labels

Internal ToolingIssues related to our tooling and monorepo infrastructorespike

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions