Skip to content

Commit 5d9837b

Browse files
committed
fix: correct typos in README for improved clarity and consistency
1 parent cd7af70 commit 5d9837b

File tree

1 file changed

+7
-7
lines changed
  • exercises/04.performance/02.solution.concurrency

1 file changed

+7
-7
lines changed

exercises/04.performance/02.solution.concurrency/README.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ test.concurrent(`${i}`, async () => {})
1212

1313
By making our test cases concurrent, we can switch from a test waterfall to a flat test execution:
1414

15-
![A diagram illustrating a test case waterfal without concurrency and a simultaneous test case execution with concurrency enabled](/assets/05-02-with-concurrency.png)
15+
![A diagram illustrating a test case waterfall without concurrency and a simultaneous test case execution with concurrency enabled](/assets/05-02-with-concurrency.png)
1616

17-
Now that our test run at the same time, it is absolutely crucial we provision proper _test isolation_. We don't want tests to be stepping on each other's toes and becoming flaky as a result. This often comes down to eliminating or replacing any shared (or global) state in test cases.
17+
Now that our tests run at the same time, it is absolutely crucial we provision proper _test isolation_. We don't want tests to be stepping on each other's toes and becoming flaky as a result. This often comes down to eliminating or replacing any shared (or global) state in test cases.
1818

19-
For example, the `expect()` function that you use to make assertions _might contain state_. It is essential we scoped that function to individual test case by accessing it from the test context object:
19+
For example, the `expect()` function that you use to make assertions _might contain state_. It is essential we scope that function to individual test case by accessing it from the test context object:
2020

2121
```ts diff remove=1 add=3
2222
test.concurrent(`${i}`, async () => {
@@ -55,7 +55,7 @@ export default defineConfig({
5555
5656
> 🦉 Bigger doesn't necessarily mean better with concurrency. There is a physical limit to any concurrency dictated by your hardware. If you set a `maxConcurrency` value higher than that limit, concurrent tests will be _queued_ until they have a slot to run.
5757
58-
By fine-tunning `maxConcurrency`, we are able to improve the test performance even further to the whooping 123ms!
58+
By fine-tuning `maxConcurrency`, we are able to improve the test performance even further to the whopping 123ms!
5959
6060
```bash remove=1 add=2
6161
Duration 271ms
@@ -66,14 +66,14 @@ By fine-tunning `maxConcurrency`, we are able to improve the test performance ev
6666
6767
While concurrency may improve performance, it can also make your tests _flaky_. Keep in mind that the main price you pay for concurrency is _writing isolated tests_.
6868
69-
Here's a few guidelines on how to keep your tests concurrency-friendly:
69+
Here are a few guidelines on how to keep your tests concurrency-friendly:
7070
71-
- **Do not rely on _shared state_ of any kind**. Never have multiple test modify the same data (even the `expect` function can become a shared state!). In practice, you achieve this through actions like:
71+
- **Do not rely on _shared state_ of any kind**. Never have multiple tests modify the same data (even the `expect` function can become a shared state!). In practice, you achieve this through actions like:
7272
- Striving toward self-contained tests (never have one test rely on the result of another);
7373
- Keeping the test setup next to the test itself;
7474
- Binding mocks (e.g. databases or network) to the test.
7575
- **Isolate side effects**. If your test absolutely must perform a side effect, like writing to a file, guarantee that those side effects are isolated and bound to the test (e.g. create a temporary file accessed only by this particular test).
76-
- **Abolish hard-coded values**. If two tests try to establish a mock server at the same port, one is destined to fail. Once again, procude test-specific fixtures (e.g. spawn a mock server at port `0` to get a random available port number).
76+
- **Abolish hard-coded values**. If two tests try to establish a mock server at the same port, one is destined to fail. Once again, produce test-specific fixtures (e.g. spawn a mock server at port `0` to get a random available port number).
7777
7878
It is worth mentioning that due to these considerations, not all test cases can be flipped to concurrent and call it a day. Concurrency can, however, be a useful factor to stress your tests and highlight the shortcomings in their design. You can then address those shortcomings in planned, incremental refactors to benefit from concurrency (among other things) once your tests are properly isolated.
7979

0 commit comments

Comments
 (0)