@pandell/jest-teamcity

0.4.2 • Public • Published

jest-teamcity

License: MIT Node.js CI npm

jest-teamcity is a modern Jest Test Result Processor for TeamCity written in TypeScript. It makes use of TeamCity service messages to pass information about the Jest test results to the TeamCity server. This makes it possible to display Jest test results in real-time and make the test information available on the Tests tab of the Build Results page.

How To Use

To use @pandell/jest-teamcity, add the package to your project and update your Jest configuration:

yarn add -D @pandell/jest-teamcity

Add a reporter to the Jest configuration file or the package.json. For details, check the Jest documentation.

// `jest.config.js`
module.export = {
    ...
    reporters: process.env.TEAMCITY_VERSION ? ["@pandell/jest-teamcity"] : ["default"],
    ...
}

The above configuration uses the custom @pandell/jest-teamcity report if the TEAMCITY_VERSION environment variable is set (as is always the case for a TeamCity agent), and uses the default reporter otherwise, resulting in a nice local development experience.

Jest terminology

  • Test: A "single" test, declared with (it/test)
  • Test Suite: A collection of individual tests (grouped with describe)
  • Test Run: A single "run" of all test suites (as specified by the CLI, config, ...)

Custom Jest reporters

@pandell/jest-teamcity is implemented as a custom Jest reporter.

A custom reporter is a class that implements onRunStart, onTestStart, onTestResult, onRunComplete methods that will be called when any of those events occurs.

See the Jest documentation for more details.

When using @pandell/jest-teamcity, we recommend replacing the default reporter so that only TeamCity service messages are written to the standard output. The default Jest reporter is overridden automatically if only specifying @pandell/jest-teamcity as a custom reporter (see #how-to-use).

Jest Test Result Processors

Jest also has the notion of test result processors. However, @pandell/jest-teamcity is deliberately implemented as a custom Jest reporter to report on the test progress live, as a reporter can receive test results after individual tests and/or test suites are finished.

Contribute

To build and contribute to this project, you require Node and the yarn package manager.

yarn

# run tests
yarn test

Create a Release

To create a new release, you need to do the following steps:

# bump package version (you can also omit the arguments and follow the interactive prompt)
git checkout main
yarn version 1.2.3

# commit and add tag
git commit --message "v1.2.3"
git tag --annotate v1.2.3 --message "1.2.3"

# push tag to remote
git push origin v1.2.3

# create a new release (using GitHub CLI)
gh release create v1.2.3

The new release triggers a new package to be pushed to NPM registry via GitHub Actions.

Alternatives

Package Sidebar

Install

npm i @pandell/jest-teamcity

Weekly Downloads

23

Version

0.4.2

License

MIT

Unpacked Size

11.8 kB

Total Files

5

Last publish

Collaborators

  • pandell-itsupport