1.2.17 • Published 28 days ago

@universal-packages/core-jest v1.2.17

Weekly downloads
-
License
MIT
Repository
github
Last release
28 days ago

Core Jest

npm version Testing codecov

Jest tooling for Universal Core testing.

Install

npm install @universal-packages/core-jest

npm install @universal-packages/core

Setup

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

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

Jest Global

jestCore.runApp(name: string, [options: Object])

Run an app for all test cases in file and stop it after all tests are done.

jestCore.runApp('web-server')

it('should return the todo list', async () => {
  const result = fetch('http://localhost:4000/todos')

  expect(result.json()).toEqual({ todos: [] })
})

Options

  • args Object Arguments to pass to the app.
  • coreConfigOverride Object Override the core config for the run.

jestCore.runBare([options: Object])

Load core modules and let them be available for code that can be tested without running an app or task.

jestCore.runBare()

it('should be able to use global modules', async () => {
  const result = await MyService.doSomething()

  expect(result).toEqual('something')
})

Options

  • coreConfigOverride Object Override the core config for the run.

jestCore.execTask(name: string, [options: Object])

Runs a task on the spot use this per test case that needs to test what the task did.

it('should do something', async () => {
  await jestCore.execTask('maintain', 'deleted-users', ['fast'])

  expect(User.deleted().count()).toEqual(0)
})

Options

  • args Object Arguments to pass to the task.

  • directive string The directive to run the task with.

  • directiveOptions string[] The directive options to run the task with.

  • coreConfigOverride Object Override the core config for the run.

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/core-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.

1.2.16

29 days ago

1.2.17

28 days ago

1.2.15

30 days ago

1.2.14

1 month ago

1.2.13

1 month ago

1.2.8

1 month ago

1.2.7

1 month ago

1.2.6

1 month ago

1.2.10

1 month ago

1.2.11

1 month ago

1.2.9

1 month ago

1.2.0

1 month ago

1.2.5

1 month ago

1.2.4

1 month ago

1.2.3

1 month ago

1.2.2

1 month ago

1.2.1

1 month ago

1.1.34

2 months ago

1.1.36

2 months ago

1.1.35

2 months ago

1.1.33

2 months ago

1.1.32

2 months ago

1.1.31

2 months ago

1.1.29

2 months ago

1.1.30

2 months ago

1.1.28

3 months ago

1.1.27

3 months ago

1.1.19

3 months ago

1.1.23

3 months ago

1.1.22

3 months ago

1.1.21

3 months ago

1.1.20

3 months ago

1.1.26

3 months ago

1.1.25

3 months ago

1.1.24

3 months ago

1.1.18

3 months ago

1.1.17

3 months ago

1.1.12

4 months ago

1.1.16

3 months ago

1.1.15

3 months ago

1.1.14

3 months ago

1.1.13

3 months ago

1.1.11

4 months ago

1.1.10

4 months ago

1.1.9

5 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.1.2

6 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago