Is there a way to keep a global state between all the tests (in different files) #3011
-
My tests are run against a local service, and they need each a unique ID (from 0 to 255). I use something like that: const getNextIndex = (function (n) {
return () => n++;
})(0); Unfortunately, it looks like each file is run in its own process, so several test are run with the same ID and conflict each other. Is there an easy way to go around this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes! Through the shared workers feature. See https://github.com/avajs/get-port for an example, that relies on https://github.com/avajs/get-port which lets you reserve a range of integers which no other test worker can then use until the first worker completes. |
Beta Was this translation helpful? Give feedback.
Yes! Through the shared workers feature.
See https://github.com/avajs/get-port for an example, that relies on https://github.com/avajs/get-port which lets you reserve a range of integers which no other test worker can then use until the first worker completes.