Détail du package

@universal-packages/workflows-jest

Jest matchers for universal workflows

readme

Workflows Jest

npm version Testing codecov

Jest matchers for Workflows testing.

Install

npm install @universal-packages/workflows-jest

npm install @universal-packages/workflows

Setup

Add the following to your jest.config.js or where you configure Jest:

module.exports = {
  setupFilesAfterEnv: ['@universal-packages/workflows-jest']
}

Matchers

toHaveFinishWithStatus

it('should be successful', async () => {
  const workflow = await workflowsJest.run('my-workflow')

  expect(workflow).toHaveFinishWithStatus('success')
})

toHaveBeenBuildAndRun

import { runApp } from './src'

workflowsJest.mockRuns()

it('should have been build and run', async () => {
  await runApp({ development: true })

  expect('development-workflow').toHaveBeenBuildAndRun()
})

toHaveBeenBuildAndRunWithVariables

import { runApp } from './src'

workflowsJest.mockRuns()

it('should have been build and run with variables', async () => {
  await runApp({ development: true, fast: true })

  expect('development-workflow').toHaveBeenBuildAndRunWithVariables({ fast: true })
})

getCommandHistory

it('should be ran commands', async () => {
  await workflowsJest.run('my-workflow')

  const commandHistory = workflowsJest.getCommandHistory()

  expect(commandHistory).toEqual([
    { command: 'git pull', workingDirectory: './my-repo' },
    { command: 'npm install', workingDirectory: './my-repo' }
  ])
})

Typescript

In order for typescript to see the global types you need to reference the types somewhere in your project, normally ./src/globals.d.ts.

/// <reference types="@universal-packages/workflows-jest" />

This library is developed in TypeScript and shipped fully typed.

Contributing

The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.

License

MIT licensed.