0.0.1 • Published 7 months ago
enable-fixtures v0.0.1
enable-fixtures
Enable fixtures (like Vitest, Playwright, or pytest) in Jest.
ATTENTION: This is a proof of concept right now. Use at your own risk.
Setup
Create a setup script with the following:
// content of testSetup.js
import { enableFixtures } from 'enable-fixtures'
enableFixtures(test, { mutate: true })
Then add the setup script to your Jest config's setupFilesAfterEnv
. For example, when
configuring via package.json
:
"jest": {
"setupFilesAfterEnv": ["<rootDir>/testSetup.js"]
}
Now Jest's global test
and it
should have a .extend
property added to them.
const myTest = test.extend({
hello: "hello fixtures!",
loudHello: async ({ hello }, use) => {
await use(hello.toUpperCase())
},
})
myTest("fixtures are working", ({ loudHello }) => {
expect(loudHello).toBe("HELLO FIXTURES!")
})
Usage
enable-fixtures
is modeled after
Vitest's test context
and Playwright's fixtures.
The main difference is that enable-fixtures
doesn't provide any default fixtures.
Furthermore, enable-fixtures
doesn't support Playwright's worker scope,
fixtures-options, or timeout. It does, however, support
automatic fixtures
via Playwright's tuple-like syntax.
0.0.1
7 months ago