Skip to content

Commit 5f1d025

Browse files
committed
docs: use long options for consistency and readability
1 parent 6ca470e commit 5f1d025

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

docs/example-react-intl.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ the component in a way that will simulate the user behavior as much as posible.
141141
| Use strings from the default language | Test is easy to read, and asserts expected default output. If you have variables in your strings, you can test that they work properly with correct output. | 1. Strings hardcoded into tests mean you have to update both tests and code for any copy changes. 2. If multiple elements have the same string/substring text, find-and-replace may be hard to use reliably. |
142142
| Mock the translation library | If your library is difficult to use in the test environment, you can mock it so it is easier. For example, you can add the message ID as a data-attribute to the text so you can query by that. | Test code deviates from what runs in production. Tests may assert about message IDs but not enough about content, so errors are possible. |
143143
| Use translation library in tests | Decouples strings from tests, so you can update the message files in one place without worrying about breaking tests. Can run tests in another language or multiple languages. `const buttonText = getNodeText(<FormattedMessage id="buttonText" defaultMessage="Hello Button" />);` | Overhead - it takes more lines of code to write the test, and you need to know the variables and message IDs to create the right strings. It's not obvious what the text actually is when you read the test code, making maintaining it harder. |
144-
| Use translation library + inline snapshots | Same as above, but by adding an inline snapshot of the string, you can read the test code and see what strings are in use, but easily update them with `jest -u` if the messages change. `expect(buttonText).toMatchInlineSnapshot("'My button text'")` | Tests are longer because of the extra lines. You can wrap up some of the translation-related code into a helper function to make it a little more inline-able and avoid repeating yourself, but you still need to know the message IDs and variables inside the test. |
144+
| Use translation library + inline snapshots | Same as above, but by adding an inline snapshot of the string, you can read the test code and see what strings are in use, but easily update them with `jest --updateSnapshot` if the messages change. `expect(buttonText).toMatchInlineSnapshot("'My button text'")` | Tests are longer because of the extra lines. You can wrap up some of the translation-related code into a helper function to make it a little more inline-able and avoid repeating yourself, but you still need to know the message IDs and variables inside the test. |

docs/marko-testing-library/api.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ You can turn off the automatic test cleanup by importing the following module:
294294
import '@marko/testing-library/dont-cleanup-after-each'
295295
```
296296

297-
With mocha you can use `mocha -r @marko/testing-library/dont-cleanup-after-each`
298-
as a shorthand.
297+
With mocha you can use
298+
`mocha --require @marko/testing-library/dont-cleanup-after-each` as a shorthand.
299299

300300
If you are using Jest, you can include
301301
`setupFilesAfterEnv: ["@marko/testing-library/dont-cleanup-after-each"]` in your

docs/marko-testing-library/setup.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ To run server-side Marko tests with `mocha` you can simply run the following
8080
command:
8181

8282
```console
83-
mocha -r marko/node-require
83+
mocha --require marko/node-require
8484
```
8585

8686
This enables the

docs/nightwatch-testing-library/intro.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ in [Nightwatch](https://nightwatchjs.org) for end-to-end web testing.
1414
then just
1515

1616
```bash npm2yarn
17-
npm install -D @testing-library/nightwatch
17+
npm install --save-dev @testing-library/nightwatch
1818
```
1919

2020
- [nightwatch-testing-library on GitHub][gh]

docs/react-testing-library/setup.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ do this with Jest's `setupFiles` configuration:
478478
Or with mocha's `-r` flag:
479479

480480
```
481-
mocha -r @testing-library/react/dont-cleanup-after-each
481+
mocha --require @testing-library/react/dont-cleanup-after-each
482482
```
483483

484484
Alternatively, you could import `@testing-library/react/pure` in all your tests
@@ -508,5 +508,5 @@ exports.mochaHooks = {
508508
And register it using mocha's `-r` flag:
509509

510510
```
511-
mocha -r ./mocha-watch-cleanup-after-each.js
511+
mocha --require ./mocha-watch-cleanup-after-each.js
512512
```

docs/webdriverio-testing-library/intro.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ queries in [WebdriverIO](https://webdriver.io/) for end-to-end web testing.
1414
then just
1515

1616
```bash npm2yarn
17-
npm install -D @testing-library/webdriverio
17+
npm install --save-dev @testing-library/webdriverio
1818
```
1919

2020
- [webdriverio-testing-library on GitHub][gh]

0 commit comments

Comments
 (0)