Skip to content

lifeomic/jest-config

Repository files navigation

jest-config

Shared Jest config utils etc.

preset

Publish a preset file for jest. Jest 29

{
  "preset": "@lifeomic/jest-config"
}

Config was extracted from lifeomic/typescript-tools

expect enhancement

Matchers can be exposed at the root level. The library needs to be imported at some level to work.

Jest-extended setup instructions

{
  "setupFiles": ["@lifeomic/jest-config"]
}

OR

{
  "setupFilesAfterEnv": ["@lifeomic/jest-config"]
}

The project can also be imported inside internal setup/test files using a setup file. setup.ts

import ('@lifeomic/jest-config');

To get typescript to see the types, it has been necessary to include something in the tsconfig.json.

{
  "include": [
    "setup.ts"
  ]
}

After importing, all matchers are now exposed at the root level, and can be not-ed.

test('has exposed some desired methods', () => {
  expect({
    numberVal: .31,
    otherNum: .3,
  }).toEqual({
    numberVal: expect.toBeCloseTo(0.3, 1),
    otherNum: expect.not.toBeCloseTo(0.2),
  });
});