0.2.0 • Published 12 months ago

@zanminkian/powerful-jest v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

@zanminkian/powerful-jest

License Version Downloads Dependencies Size

@zanminkian/powerful-jest is now typed-jest. Use typed-jest instead.

Empower your Jest testing experience.

Features

  • 100% compatible with Jest. Use @zanminkian/powerful-jest just like you would use jest.
  • Out-of-the-box TypeScript support.
  • Sensible defaults adhering to best practices. Most projects work seamlessly with zero configuration.
  • Integrated supertest in it.

Usage

  1. Uninstall jest, @types/jest, and ts-jest if they are already installed in your project.
pnpm remove jest @types/jest ts-jest
  1. Install @zanminkian/powerful-jest.
pnpm add -D @zanminkian/powerful-jest
  1. Create an app.ts file.
import express from 'express'

const app = express()
app.use((req, res) => {
  res.json({ hello: 'world' })
})

export default app
  1. Create an app.spec.ts file.
import { describe, beforeEach, it, expect, supertest } from '@zanminkian/powerful-jest'
import app from './app'

describe('app', () => {
  beforeEach(() => {
    // This will be executed before each test case.
  })

  afterEach(() => {
    jest.resetAllMocks()
  })

  it('should be 2', () => {
    expect(1 + 1).toBe(2)
  })
  it('should success', () => {
    supertest(app).get('/').expect({ hello: 'world' })
  })
})
  1. Run pnpm jest to execute tests.

Configuration

  1. Add more CLI configurations after the pnpm jest command. For example, run pnpm jest --coverage to collect test coverage. Run pnpm jest -h for more CLI options information.
  2. Add a jest.config.js file in the root of your project. Consult the official Jest documentation for more information.

How it works

If you don't include CLI options when running pnpm jest, we will append some sensible defaults:

  • --transform='{"^.+\\\\.tsx?$":"ts-jest"}': This option transforms TypeScript files, so you can support TypeScript projects without additional configurations or installations.
  • --passWithNoTests: This option prevents the CLI from producing errors if no tests are found. You can override this default by pnpm jest --passWithNoTests=false.
  • --collectCoverageFrom='**/src/**/*.{(j|t)s,(j|t)sx}': This option specifies the location for collecting test coverage. Override it as needed: pnpm jest --collectCoverageFrom='**/lib/**/*.js'

License

MIT

0.1.12

12 months ago

0.2.0

12 months ago

0.1.12-beta.0

12 months ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.8

1 year ago

0.1.9

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago