Skip to content

Project created to demonstrate how how to have Two Testing Frameworks - Karma and Jest in one project. Karma is already used to execute standard Unit Tests which are already present in project. And then since Pact does not support Karma, we use Jest to run only Contract Tests written using Pact.

Notifications You must be signed in to change notification settings

subodhgodbole/angular-pact

Repository files navigation

angular-pact

Since Pact has deprecated support for Karma with 10.x version. This project showcases, how you can have Karma and Jest both Testing Frameworks together in one project and -

  • Write and execute (new) Pact tests using Jest.
  • And continue using Karma for executing existing unit tests (until you migrate).

Commands

  • Running tests using Karma - Files ending with .karma.spec.ts are considered.
npm run test
  • Running standard Unit Tests using Jest - Files ending with .jest.spec.ts are considered.
npm run test:jest
  • Running Pact Tests using Jest - Files ending with .pact.spec.ts are considered.
npm run test:pact

Note: I tried using below Regex, which uses lookbehind. This way Karma considers all ".spec.ts" files except ones ending with .pact.spec.ts and .jest.spec.ts. This way we do not have to rename existing Karma test files with ".karma.spec.ts". But this did not work!

// In src/test.ts
const context = require.context('./', true, /.*(?<!(jest|pact))\.spec\.ts/);

About

Project created to demonstrate how how to have Two Testing Frameworks - Karma and Jest in one project. Karma is already used to execute standard Unit Tests which are already present in project. And then since Pact does not support Karma, we use Jest to run only Contract Tests written using Pact.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published