Skip to content

Commit bff9166

Browse files
TG199JoshuaKGoldbergmark-wiemer
authored
Docs: migrate remaining legacy wiki pages to main documentation (#5465)
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com> Co-authored-by: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Co-authored-by: Mark Wiemer <markwiemer@outlook.com>
1 parent c805327 commit bff9166

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

docs-next/astro.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ export default defineConfig({
108108
label: "Detecting multiple calls to done()",
109109
slug: "explainers/detecting-multiple-calls-to-done",
110110
},
111+
{
112+
label: "Compilers deprecation",
113+
slug: "explainers/compilers-deprecation",
114+
},
111115
{
112116
label: "Counting assertions",
113117
slug: "explainers/count-assertions",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
description: Compilers deprecation notice.
3+
title: Compilers deprecation
4+
---
5+
6+
If you're here, you probably hit the deprecation notice. Sorry about that!
7+
8+
## Will it break?
9+
10+
This is a *soft* deprecation, which means you get nagged about it, but it won't break (yet).
11+
12+
## Make it go away
13+
14+
To suppress this warning, execute `mocha` with the `--no-deprecation` flag (though you won't get notice of any *other* deprecations you may encounter either).
15+
16+
## ... but why?
17+
18+
`--compilers` is redundant; we've yet to encounter a real-world situation in which the solution couldn't be expressed using `--require`.
19+
20+
## What should I use instead then?
21+
22+
Let's say you want to compile using CoffeeScript. Ensure that you have the coffeescript package installed as a dev dependency:
23+
24+
```npm install coffeescript --save-dev```
25+
26+
Then update your package.json with the relevant require statement: `--require coffeescript/register`.
27+
28+
Here's a list of popular compilers/transpilers:
29+
30+
- CoffeeScript: `--compilers coffee:coffee-script/register` becomes `--require coffeescript/register`
31+
- Babel 6: `--compilers js:babel-core/register` becomes `--require babel-core/register`
32+
- Babel 7: `--require babel-core/register` used if you are using Babel v6 becomes `--require @babel/register` with Babel v7.
33+
- TypeScript: `--compilers ts:ts-node/register` becomes `--require ts-node/register`
34+
- LiveScript: `--compilers ls:livescript` becomes `--require livescript`
35+
- (feel free to add more examples!)
36+
37+
You'll have to handle file extensions as well. Mocha, by default, only loads `.js` files when given a directory (and the default directory is `test`). Therefore, to use a *different* file extension (such as `.coffee` or `.ts`), you will need to supply a *glob* instead of simply a directory. If this was how you ran Mocha pre-v4:
38+
39+
```bash
40+
$ mocha --compilers coffee:coffee-script/register --recursive ./test
41+
```
42+
43+
Then this is how you'd accomplish the same thing (`**` roughly means "recursive") in v4:
44+
45+
```bash
46+
$ mocha --require coffeescript/register "test/**/*.js"
47+
```
48+
49+
When you wrap a glob in quotes, file discovery is handed to the [glob](https://npm.im/glob) package.
50+
It's *recommended* to wrap in double-quotes, because the result should be the same regardless of your shell or environment (Windows/Linux/macOS, etc.).
51+
52+
[glob](https://npm.im/glob) is powerful. For instance, if your `test` dir has tests written in *both* JS *and* CoffeeScript, you could do this:
53+
54+
```bash
55+
$ mocha --require coffeescript/register "test/**/*.{js,coffee}"
56+
```
57+
58+
## How do I use this with `--watch`?
59+
60+
When using `--watch`, you will also need to specify the extension(s) to watch via `--watch-extensions`, e.g.:
61+
62+
```js
63+
$ mocha --require coffeescript/register --watch --watch-extensions js,coffee "test/**/*.{js,coffee}"
64+
```
65+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
If you're here, you probably hit the deprecation notice. Sorry about that!
2+
3+
## Will it break?
4+
5+
This is a _soft_ deprecation, which means you get nagged about it, but it won't break (yet).
6+
7+
## Make it go away
8+
9+
To suppress this warning, execute `mocha` with the `--no-deprecation` flag (though you won't get notice of any _other_ deprecations you may encounter either).
10+
11+
## ... but why?
12+
13+
`--compilers` is redundant; we've yet to encounter a real-world situation in which the solution couldn't be expressed using `--require`.
14+
15+
## What should I use instead then?
16+
17+
Let's say you want to compile using CoffeeScript. Ensure that you have the coffeescript package installed as a dev dependency:
18+
19+
`npm install coffeescript --save-dev`
20+
21+
Then update your package.json with the relevant require statement: `--require coffeescript/register`.
22+
23+
Here's a list of popular compilers/transpilers:
24+
25+
- CoffeeScript: `--compilers coffee:coffee-script/register` becomes `--require coffeescript/register`
26+
- Babel 6: `--compilers js:babel-core/register` becomes `--require babel-core/register`
27+
- Babel 7: `--require babel-core/register` used if you are using Babel v6 becomes `--require @babel/register` with Babel v7.
28+
- TypeScript: `--compilers ts:ts-node/register` becomes `--require ts-node/register`
29+
- LiveScript: `--compilers ls:livescript` becomes `--require livescript`
30+
- (feel free to add more examples!)
31+
32+
You'll have to handle file extensions as well. Mocha, by default, only loads `.js` files when given a directory (and the default directory is `test`). Therefore, to use a _different_ file extension (such as `.coffee` or `.ts`), you will need to supply a _glob_ instead of simply a directory. If this was how you ran Mocha pre-v4:
33+
34+
```bash
35+
$ mocha --compilers coffee:coffee-script/register --recursive ./test
36+
```
37+
38+
Then this is how you'd accomplish the same thing (`**` roughly means "recursive") in v4:
39+
40+
```bash
41+
$ mocha --require coffeescript/register "test/**/*.js"
42+
```
43+
44+
When you wrap a glob in quotes, file discovery is handed to the [glob](https://npm.im/glob) package.
45+
It's _recommended_ to wrap in double-quotes, because the result should be the same regardless of your shell or environment (Windows/Linux/macOS, etc.).
46+
47+
[glob](https://npm.im/glob) is powerful. For instance, if your `test` dir has tests written in _both_ JS _and_ CoffeeScript, you could do this:
48+
49+
```bash
50+
$ mocha --require coffeescript/register "test/**/*.{js,coffee}"
51+
```
52+
53+
## How do I use this with `--watch`?
54+
55+
When using `--watch`, you will also need to specify the extension(s) to watch via `--watch-extensions`, e.g.:
56+
57+
```js
58+
$ mocha --require coffeescript/register --watch --watch-extensions js,coffee "test/**/*.{js,coffee}"
59+
```
60+
61+
## This isn't working
62+
63+
Any questions or trouble? Ask for help [in our Gitter chat room](https://gitter.im/mochajs/mocha)!

docs/api-tutorials/jsdoc.tutorials.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"compilers-deprecation": {
3+
"title": "Compilers deprecation"
4+
},
25
"count-assertions": {
36
"title": "Count assertions"
47
},

0 commit comments

Comments
 (0)