Skip to content

Commit a4c7692

Browse files
committed
docs(readme): use github alert syntax
1 parent 90819cd commit a4c7692

1 file changed

Lines changed: 69 additions & 17 deletions

File tree

README.md

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ pluginTester({
176176
});
177177
```
178178

179+
> [!TIP]
180+
>
179181
> Note how `pluginTester` does not appear inside any `test`/`it` block nor
180182
> within any [hook functions][10]. For advanced use cases, `pluginTester` may
181183
> appear within one or more `describe` blocks, though this is discouraged.
@@ -460,6 +462,8 @@ available, and it is used as the default value for `babelOptions.filename` in
460462
This option defaults to the absolute path of the file that [invoked the
461463
`pluginTester` function][43].
462464

465+
> [!NOTE]
466+
>
463467
> For backwards compatibility reasons, `filepath` is synonymous with `filename`.
464468
> They can be used interchangeably, though care must be taken not to confuse the
465469
> babel-plugin-tester option `filename` with `babelOptions.filename`. They are
@@ -478,6 +482,8 @@ the expected output will be converted to. Defaults to `"lf"`.
478482
| `"preserve"` | Use the line endings from the input |
479483
| `false` | Disable line ending conversion entirely |
480484

485+
> [!NOTE]
486+
>
481487
> When disabling line ending conversion, note that [Babel will always output
482488
> LF][44] even if the input is CRLF.
483489
@@ -639,6 +645,11 @@ fixtures
639645
└── exec.js # required (alternative to code/output structure)
640646
```
641647

648+
> [!TIP]
649+
>
650+
> `.babelrc`, `.babelrc.json`, `.babelrc.js`, `.babelrc.cjs`, and `.babelrc.mjs`
651+
> config files in fixture directories are supported out-of-the-box.
652+
642653
Assuming the `fixtures` directory is in the same directory as your test file,
643654
you could use it with the following configuration:
644655

@@ -649,14 +660,11 @@ pluginTester({
649660
});
650661
```
651662

663+
> [!NOTE]
664+
>
652665
> If `fixtures` is not an absolute path, it will be [`path.join`][40]'d with the
653666
> [directory name][41] of [`filepath`][54].
654667
655-
> `.babelrc`, `.babelrc.json`, `.babelrc.js`, `.babelrc.cjs`, and `.babelrc.mjs`
656-
> config files in fixture directories are technically supported out-of-the-box,
657-
> though `.mjs` config files will cause a segfault in Jest until [this issue
658-
> with V8/Chromium is resolved][55].
659-
660668
And it would run four tests, one for each directory in `fixtures` containing a
661669
file starting with "code" or "exec".
662670

@@ -713,6 +721,8 @@ file might contain:
713721
expect(() => throw new Error('throw expression')).toThrow('throw expression');
714722
```
715723

724+
> [!CAUTION]
725+
>
716726
> Keep in mind that, despite sharing a global context, execution will occur in a
717727
> [separate realm][63], which means native/intrinsic types will be different.
718728
> This can lead to unexpectedly failing tests. For example:
@@ -829,6 +839,8 @@ Use this to run only the specified fixture. Useful while developing to help
829839
focus on a small number of fixtures. Can be used in multiple `options.json`
830840
files.
831841
842+
> [!IMPORTANT]
843+
>
832844
> Requires [Jest][66], an equivalent interface (like [Vitest][8]), or a
833845
> manually-defined `it` object exposing an appropriate [`only`][67] method.
834846
@@ -838,11 +850,15 @@ Use this to skip running the specified fixture. Useful for when you are working
838850
on a feature that is not yet supported. Can be used in multiple `options.json`
839851
files.
840852
853+
> [!IMPORTANT]
854+
>
841855
> Requires [Jest][66], an equivalent interface (like [Vitest][8]), or a
842856
> manually-defined `it` object exposing an appropriate [`skip`][68] method.
843857
844858
###### `throws`
845859
860+
> [!IMPORTANT]
861+
>
846862
> When using certain values, this property must be used in `options.js` instead
847863
> of `options.json`.
848864
@@ -864,23 +880,27 @@ an error during transformation. For example:
864880
}
865881
```
866882
883+
> [!CAUTION]
884+
>
867885
> Be careful using `instanceof` [across realms][69] as it can lead to [strange
868886
> behavior][70] with [frontend frames/windows][71] and with tools that rely on
869-
> [Node's VM module][72] (like Jest). Prefer [name checks][73] and utilities
870-
> like [`isNativeError`][74], [`Array.isArray`][75], and overriding
871-
> [`Symbol.hasInstance`][76] instead.
887+
> [Node's VM module][72] (like Jest).
872888
873889
If the value of `throws` is a class, that class must [be a subtype of
874890
`Error`][77] or the behavior of babel-plugin-tester is undefined.
875891

876-
> For backwards compatibility reasons, `throws` is synonymous with `error`. They
877-
> can be used interchangeably, with `throws` taking precedence.
878-
879892
Note that this property cannot be present when using an [`exec.js`][58] or
880893
[`output.js`][56] file or when using the [`outputRaw`][78] option.
881894

895+
> [!NOTE]
896+
>
897+
> For backwards compatibility reasons, `throws` is synonymous with `error`. They
898+
> can be used interchangeably, with `throws` taking precedence.
899+
882900
###### `setup`
883901

902+
> [!IMPORTANT]
903+
>
884904
> As it requires a function value, this property must be used in `options.js`
885905
> instead of `options.json`.
886906
@@ -894,6 +914,8 @@ as a babel-plugin-tester option. See [here][46] for the complete run order.
894914

895915
###### `teardown`
896916

917+
> [!IMPORTANT]
918+
>
897919
> As it requires a function value, this property must be used in `options.js`
898920
> instead of `options.json`.
899921
@@ -908,6 +930,8 @@ by the [`setup`][80] property, both of which will run _before_ any
908930

909931
###### `formatResult`
910932

933+
> [!IMPORTANT]
934+
>
911935
> As it requires a function value, this property must be used in `options.js`
912936
> instead of `options.json`.
913937
@@ -923,6 +947,12 @@ babel-plugin-tester.
923947

924948
###### `outputRaw`
925949

950+
> [!WARNING]
951+
>
952+
> This feature is only available in `babel-plugin-tester@>=12`.
953+
954+
> [!IMPORTANT]
955+
>
926956
> As it requires a function value, this property must be used in `options.js`
927957
> instead of `options.json`.
928958
@@ -1039,6 +1069,8 @@ will be determined from test object by default.
10391069
Use this to run only the specified test. Useful while developing to help focus
10401070
on a small number of tests. Can be used on multiple tests.
10411071

1072+
> [!IMPORTANT]
1073+
>
10421074
> Requires [Jest][66], an equivalent interface (like [Vitest][8]), or a
10431075
> manually-defined `it` object exposing an appropriate [`only`][67] method.
10441076
@@ -1047,6 +1079,8 @@ on a small number of tests. Can be used on multiple tests.
10471079
Use this to skip running the specified test. Useful for when you are working on
10481080
a feature that is not yet supported. Can be used on multiple tests.
10491081

1082+
> [!IMPORTANT]
1083+
>
10501084
> Requires [Jest][66], an equivalent interface (like [Vitest][8]), or a
10511085
> manually-defined `it` object exposing an appropriate [`skip`][68] method.
10521086
@@ -1070,22 +1104,24 @@ error during transformation. For example:
10701104
}
10711105
```
10721106

1107+
> [!CAUTION]
1108+
>
10731109
> Be careful using `instanceof` [across realms][69] as it can lead to [strange
10741110
> behavior][70] with [frontend frames/windows][71] and with tools that rely on
1075-
> [Node's VM module][72] (like Jest). Prefer [name checks][73] and utilities
1076-
> like [`isNativeError`][74], [`Array.isArray`][75], and overriding
1077-
> [`Symbol.hasInstance`][76] instead.
1111+
> [Node's VM module][72] (like Jest).
10781112
10791113
If the value of `throws` is a class, that class must [be a subtype of
10801114
`Error`][77] or the behavior of babel-plugin-tester is undefined.
10811115

1082-
> For backwards compatibility reasons, `throws` is synonymous with `error`. They
1083-
> can be used interchangeably, with `throws` taking precedence.
1084-
10851116
Note that this property cannot be present when using the [`output`][87],
10861117
[`outputRaw`][88], [`outputFixture`][37], [`exec`][89], [`execFixture`][38], or
10871118
[`snapshot`][50] properties.
10881119

1120+
> [!NOTE]
1121+
>
1122+
> For backwards compatibility reasons, `throws` is synonymous with `error`. They
1123+
> can be used interchangeably, with `throws` taking precedence.
1124+
10891125
###### `setup`
10901126

10911127
This function will be run before a particular test is run. It can return a
@@ -1132,6 +1168,8 @@ Note that this property cannot appear in the same test object as the
11321168
[`output`][87], [`outputFixture`][37], [`exec`][89], [`execFixture`][38], or
11331169
[`throws`][84] properties. However, it _can_ be used with [`outputRaw`][88].
11341170

1171+
> [!IMPORTANT]
1172+
>
11351173
> Requires [Jest][66], an [appropriate shim][92] or equivalent interface (like
11361174
> [Vitest][8]), or a manually-defined `expect` object exposing an appropriate
11371175
> [`toMatchSnapshot`][93] method.
@@ -1167,6 +1205,10 @@ Note that this property cannot appear in the same test object as the
11671205

11681206
###### `outputRaw`
11691207

1208+
> [!WARNING]
1209+
>
1210+
> This feature is only available in `babel-plugin-tester@>=12`.
1211+
11701212
This property is similar to [`output`][87] and related properties except it
11711213
tests against the _entire [`BabelFileResult`][82] object_ returned by [babel's
11721214
`transform` function][83] instead of only the `code` property of
@@ -1230,6 +1272,8 @@ following:
12301272
}
12311273
```
12321274

1275+
> [!CAUTION]
1276+
>
12331277
> Keep in mind that, despite sharing a global context, execution will occur in a
12341278
> [separate realm][63], which means native/intrinsic types will be different.
12351279
> This can lead to unexpectedly failing tests. For example:
@@ -1292,9 +1336,13 @@ trimmed, line endings [converted][57], and then get [formatted by prettier][39].
12921336
Like [`code`][86], this property cannot appear in the same test object as the
12931337
[`exec`][89] or [`execFixture`][38] properties, nor the [`code`][86] property.
12941338
1339+
> [!TIP]
1340+
>
12951341
> If you find you are using this property more than a couple of times, consider
12961342
> using [`fixtures`][35] instead.
12971343
1344+
> [!NOTE]
1345+
>
12981346
> For backwards compatibility reasons, `codeFixture` is synonymous with
12991347
> `fixture`. They can be used interchangeably, though care must be taken not to
13001348
> confuse the test object property `fixture` with the babel-plugin-tester option
@@ -1315,6 +1363,8 @@ Like [`output`][87], this property cannot appear in the same test object as the
13151363
properties, nor the [`output`][87] property. However, it _can_ be used with
13161364
[`outputRaw`][88].
13171365
1366+
> [!TIP]
1367+
>
13181368
> If you find you are using this property more than a couple of times, consider
13191369
> using [`fixtures`][35] instead.
13201370
@@ -1334,6 +1384,8 @@ Like [`exec`][89], this property cannot appear in the same test object as the
13341384
[`throws`][84], or [`snapshot`][50] properties, nor the [`exec`][89] property.
13351385
However, it _can_ be used with [`outputRaw`][88].
13361386
1387+
> [!TIP]
1388+
>
13371389
> If you find you are using this property more than a couple of times, consider
13381390
> using [`fixtures`][35] instead.
13391391

0 commit comments

Comments
 (0)