Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions .github/workflows/mocha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,12 @@ on:
branches:
- main
paths-ignore:
[
"*.md",
"docs/**",
"docs-next/**",
".github/**",
".prettierignore",
"AUTHORS",
"LICENSE",
]
["*.md", "docs/**", ".github/**", ".prettierignore", "AUTHORS", "LICENSE"]
pull_request:
branches:
- main
paths-ignore:
[
"*.md",
"docs/**",
"docs-next/**",
".github/**",
".prettierignore",
"AUTHORS",
"LICENSE",
]
["*.md", "docs/**", ".github/**", ".prettierignore", "AUTHORS", "LICENSE"]
types: [opened, synchronize, reopened, edited]
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="docs-next/src/components/mocha-logo.svg" alt="Mocha test framework logo"/>
<img src="docs/src/components/mocha-logo.svg" alt="Mocha test framework logo"/>
</p>

<p align="center">☕️ Classic, reliable, trusted test framework for Node.js and the browser ☕️</p>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs-next/README.md → docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is the current Mocha documentation website, hosted at [mochajs.org](https:/
To run this site:

```shell
cd docs-next
cd docs
npm i
npm run generate
npm run dev
Expand Down
3 changes: 1 addition & 2 deletions docs/_data/supporters.js → docs/_data/supporters.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ const getSupporters = async () => {
}
debug("supporter image pull completed");

// TODO: For now, this supporters.js script is used both in the classic docs (docs/) and next (docs-next/).
// Eventually, we'll sunset the classic docs and only have docs-next.
// TODO: we'll sunset the classic docs and only have docs.
// At that point we'll have supporters.js only used for writing files.
if (process.argv.includes("--write-supporters-json")) {
await mkdir("src/content/data", { recursive: true });
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions docs-next/netlify.toml → docs/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[build]
command = "npm run docs"
publish = "docs-next/dist/"
publish = "docs/dist/"

[build.environment]
DEBUG = "mocha:docs*"
NODE_VERSION = "24"

[context.deploy-preview]
command = "npm run docs"
publish = "docs-next/dist/"
publish = "docs/dist/"
5 changes: 3 additions & 2 deletions docs-next/package-lock.json → docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions docs-next/package.json → docs/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "docs-next",
"name": "docs",
"type": "module",
"version": "0.0.1",
"scripts": {
"astro": "astro",
"build": "astro check && astro build",
"dev": "astro dev",
"docs": "cd .. && npm i && cd docs-next && npm i && npm run generate && npm run build && cp _redirects dist/_redirects",
"generate": "node ../docs/_data/supporters.js --write-supporters-json",
"docs": "cd .. && npm i && cd docs && npm i && npm run generate && npm run build && cp _redirects dist/_redirects",
"generate": "node _data/supporters.cjs --write-supporters-json",
"lint:knip": "knip --cache",
"preview": "astro preview",
"start": "astro dev"
Expand All @@ -20,6 +20,7 @@
"typescript": "^5.9.3"
},
"devDependencies": {
"debug": "^4.4.3",
"knip": "^5.83.1"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,34 @@ Creating a Third Party UI involves listening for the `pre-require` event emitted
In this first brief example, we'll create an interface with only a single function: `test`

```javascript
import Mocha from 'mocha'
import MochaInterface from 'mocha/lib/interfaces/common.js';
import Mocha from "mocha";
import MochaInterface from "mocha/lib/interfaces/common.js";

const Test = Mocha.Test;
/**
* A simple UI that only exposes a single function: test
*/
function SimpleUI(suite) {
suite.on('pre-require', function(
context,
file,
mocha
) {
const common = MochaInterface(
[suite],
context
);
suite.on("pre-require", function (context, file, mocha) {
const common = MochaInterface([suite], context);

context.run = mocha.options.delay && common.runWithSuite(suite);

/**
* Describes a specification or test-case with the given `title`
* and callback `fn` acting as a thunk.
*/
context.test = function(title, fn) {
context.test = function (title, fn) {
const test = new Test(title, fn);
test.file = file;
suite.addTest(test);

return test;
};
});
};
}

Mocha.interfaces['simple-ui'] = SimpleUI;
Mocha.interfaces["simple-ui"] = SimpleUI;

export default SimpleUI;
```
Expand Down Expand Up @@ -80,9 +73,9 @@ $ mocha --require ./simple-ui.js --ui simple-ui test.js
In this next example, we'll be extending the [TDD interface](https://github.com/mochajs/mocha/blob/master/lib/interfaces/tdd.js) with a comment function that simply prints the passed text. That is, `comment('This is a comment');` would print the string.

```javascript
import Mocha from 'mocha';
import MochaInterface from 'mocha/lib/interfaces/common.js';
import escapeStringRegexp from 'escape-string-regexp';
import Mocha from "mocha";
import MochaInterface from "mocha/lib/interfaces/common.js";
import escapeStringRegexp from "escape-string-regexp";

const Test = Mocha.Test;
const Suite = Mocha.Suite;
Expand Down Expand Up @@ -201,9 +194,9 @@ function ExampleUI(suite) {
*/
context.test.skip = common.test.skip;
});
};
}

Mocha.interfaces['example-ui'] = ExampleUI;
Mocha.interfaces["example-ui"] = ExampleUI;

export default ExampleUI;
```
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module.exports = defineConfig(
".karma/**",
"**/*.{fixture,min}.{js,mjs}",
"coverage/**",
"docs-next/{.astro,dist}/**",
"docs/{.astro,dist}/**",
"mocha.js",
"out/**",
"test/integration/fixtures/**",
Expand Down
11 changes: 11 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build]
Comment thread
mark-wiemer marked this conversation as resolved.
command = "npm run docs"
publish = "docs/dist/"

[build.environment]
DEBUG = "mocha:docs*"
NODE_VERSION = "24"

[context.deploy-preview]
command = "npm run docs"
publish = "docs/dist/"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"scripts": {
"build": "rollup -c ./rollup.config.mjs",
"clean": "rimraf mocha.js mocha.js.map",
"docs": "cd docs-next; npm run docs",
"docs": "cd docs; npm run docs",
"format:check": "prettier --check .",
"format:fix": "prettier --write .",
"lint:installed-check": "installed-check --engine-check --ignore-dev",
Expand Down