Created
March 8, 2024 15:42
-
-
Save benbenbenbenbenben/af3ea0ada5eb2d24b432544f7c5a16da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exploring vitest behaviour with --pool=forks vs --pool=threads | |
// spoiler alert: same module, same behaviour - server is only created *once* | |
import { describe, expect, it } from "vitest"; | |
const server = { | |
a: 0 | |
} | |
describe("some module", () => { | |
it.each([ | |
{ foo: 1, bar: 2, sum: 3 }, | |
{ foo: 3, bar: 4, sum: 7 }, | |
])( | |
"testing with foo=$foo and bar=$bar, sum=$sum", | |
async ({ foo, bar, sum }) => { | |
server.a += foo + bar | |
expect(server.a).toBe(sum) | |
}) | |
}) | |
describe("another module", () => { | |
it.each([ | |
{ foo: 1, bar: 2, sum: 3 }, | |
{ foo: 3, bar: 4, sum: 7 }, | |
])( | |
"testing with foo=$foo and bar=$bar, sum=$sum", | |
async ({ foo, bar, sum }) => { | |
server.a += foo + bar | |
expect(server.a).toBe(sum) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment