Skip to content

Commit e96650e

Browse files
authored
docs: improve tabs and package manager scripts (#1339)
1 parent 69f0b95 commit e96650e

File tree

12 files changed

+18
-53
lines changed

12 files changed

+18
-53
lines changed

docs/bs-react-testing-library/intro.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Bindings for several testing libraries have been ported to [ReasonML][re].
1515

1616
```bash npm2yarn
1717
npm install --save-dev bs-dom-testing-library
18+
```
19+
20+
```bash npm2yarn
1821
npm install --save-dev bs-react-testing-library
1922
```
2023

docs/dom-testing-library/api-custom-queries.mdx

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ id: api-custom-queries
33
title: Custom Queries
44
---
55

6-
import Tabs from '@theme/Tabs'
7-
import TabItem from '@theme/TabItem'
8-
96
`DOM Testing Library` exposes many of the helper functions that are used to
107
implement the default queries. You can use the helpers to build custom queries.
118
For example, the code below shows a way to override the default `testId` queries

docs/dom-testing-library/api-debugging.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ value is `7000`. You will see `...` in the console, when the DOM content is
3232
stripped off, because of the length you have set or due to default size limit.
3333
Here's how you might increase this limit when running tests:
3434

35-
```
35+
```bash npm2yarn
3636
DEBUG_PRINT_LIMIT=10000 npm test
3737
```
3838

@@ -46,7 +46,7 @@ colors, such as in cases where the output is written to a log file for debugging
4646
purposes. You can use the environment variable `COLORS` to explicitly force the
4747
colorization off or on. For example:
4848

49-
```
49+
```bash npm2yarn
5050
COLORS=false npm test
5151
```
5252

docs/ecosystem-user-event.mdx

+1-17
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ id: ecosystem-user-event
33
title: user-event v13
44
---
55

6-
import Tabs from '@theme/Tabs'
7-
import TabItem from '@theme/TabItem'
8-
96
[`user-event`][gh] is a companion library for Testing Library that provides more
107
advanced simulation of browser interactions than the built-in
118
[`fireEvent`](dom-testing-library/api-events.mdx#fireevent) method.
@@ -21,23 +18,10 @@ fixes and new features.
2118

2219
## Installation
2320

24-
<Tabs defaultValue="npm" values={[{ label: 'npm', value: 'npm' }, { label: 'Yarn', value: 'yarn' }]}>
25-
<TabItem value="npm">
26-
27-
```sh
21+
```bash npm2yarn
2822
npm install --save-dev @testing-library/user-event @testing-library/dom
2923
```
3024

31-
</TabItem>
32-
<TabItem value="yarn">
33-
34-
```sh
35-
yarn add --dev @testing-library/user-event @testing-library/dom
36-
```
37-
38-
</TabItem>
39-
</Tabs>
40-
4125
Now simply import it in your tests:
4226

4327
```js

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/svelte-testing-library/setup.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ npm install --save-dev @vitest/ui
8787
how) and run the following command to run the tests.
8888

8989
```bash npm2yarn
90-
npm run test
90+
npm test
9191
```
9292

9393
## Jest
@@ -104,7 +104,7 @@ npm install --save-dev @vitest/ui
104104
{
105105
"scripts": {
106106
"test": "jest src",
107-
"test:watch": "npm run test -- --watch"
107+
"test:watch": "jest src --watch"
108108
}
109109
}
110110
```
@@ -180,7 +180,7 @@ npm install --save-dev @vitest/ui
180180
and run it
181181

182182
```bash npm2yarn
183-
npm run test
183+
npm test
184184
```
185185

186186
### TypeScript

docs/user-event/install.mdx

+1-20
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,10 @@ id: install
33
title: Installation
44
---
55

6-
import Tabs from '@theme/Tabs'
7-
import TabItem from '@theme/TabItem'
8-
9-
<Tabs defaultValue="npm" values={[
10-
{ label: 'npm', value: 'npm' },
11-
{ label: 'Yarn', value: 'yarn' },
12-
]}>
13-
<TabItem value="npm">
14-
15-
```sh
6+
```bash npm2yarn
167
npm install --save-dev @testing-library/user-event
178
```
189

19-
</TabItem>
20-
<TabItem value="yarn">
21-
22-
```sh
23-
yarn add --dev @testing-library/user-event
24-
```
25-
26-
</TabItem>
27-
</Tabs>
28-
2910
Note that `@testing-library/user-event` requires `@testing-library/dom`.
3011

3112
If you use one of the

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)