0.2.0 • Published 2 years ago
@zanminkian/powerful-jest v0.2.0
@zanminkian/powerful-jest
@zanminkian/powerful-jestis nowtyped-jest. Usetyped-jestinstead.
Empower your Jest testing experience.
Features
- 100% compatible with Jest. Use
@zanminkian/powerful-jestjust like you would usejest. - Out-of-the-box TypeScript support.
- Sensible defaults adhering to best practices. Most projects work seamlessly with zero configuration.
- Integrated supertest in it.
Usage
- Uninstall
jest,@types/jest, andts-jestif they are already installed in your project.
pnpm remove jest @types/jest ts-jest- Install
@zanminkian/powerful-jest.
pnpm add -D @zanminkian/powerful-jest- Create an
app.tsfile.
import express from 'express'
const app = express()
app.use((req, res) => {
res.json({ hello: 'world' })
})
export default app- Create an
app.spec.tsfile.
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' })
})
})- Run
pnpm jestto execute tests.
Configuration
- Add more CLI configurations after the
pnpm jestcommand. For example, runpnpm jest --coverageto collect test coverage. Runpnpm jest -hfor more CLI options information. - Add a
jest.config.jsfile 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 bypnpm 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
2 years ago
0.2.0
2 years ago
0.1.12-beta.0
2 years ago
0.1.10
3 years ago
0.1.11
2 years ago
0.1.8
3 years ago
0.1.9
3 years ago
0.1.7
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago