Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Mocha 10.3.0 #96

Merged
merged 2 commits into from
Mar 18, 2024
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
1,664 changes: 1,019 additions & 645 deletions package-lock.json

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@
"license": "ISC",
"devDependencies": {
"@types/chai": "^4",
"@types/debug": "^4",
"@types/mocha": "^8",
"@types/node": "^16",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@nx/js": "^17.2.3",
"chai": "^4.3.6",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"mocha": "^10.2.0",
"prettier": "^2.5.1",
"tsx": "^4.6.2",
"typescript": "^4.5.5",
"ws": "^8.4.2",
"nx": "^17.2.3"
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@nx/js": "^18.1.1",
"chai": "^5.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"mocha": "^10.3.0",
"prettier": "^3.2.5",
"tsx": "^4.7.1",
"typescript": "^5.4.2",
"ws": "^8.16.0",
"nx": "^18.1.1"
},
"eslintConfig": {
"root": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "..";

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

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

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"version": "1.8.0",
"description": "Run Mocha tests somewhere - get reporting elsewhere",
"scripts": {
"build": "tsc --project tsconfig.build.json --emitDeclarationOnly && rollup -c",
"build": "rollup -c",
"prepack": "cp ../../README.md .",
"test": "mocha"
},
"main": "dist/node.bundle.cjs.js",
"module": "dist/node.bundle.es.js",
"browser": "dist/browser.bundle.es.js",
"types": "dist/index.d.ts",
"type": "module",
"main": "dist/node.bundle.cjs",
"module": "dist/node.bundle.mjs",
"browser": "dist/browser.bundle.mjs",
"types": "dist/bundle.d.ts",
"author": {
"name": "Kræn Hansen",
"email": "[email protected]",
Expand All @@ -26,27 +27,27 @@
},
"bugs": "https://github.com/kraenhansen/mocha-remote/issues",
"license": "ISC",
"dependencies": {
"debug": "^4.3.4",
"fast-equals": "^2.0.4",
"mocha-remote-common": "1.8.0",
"mocha": "10.3.0",
"ws": "^8.4.2"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/mocha": "^8.2.2",
"@types/ws": "^7.4.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"chai": "^4.3.4",
"mocha-remote-mocha": "1.8.0",
"rollup": "^2.42.4",
"rollup": "^4.13.0",
"rollup-plugin-dts": "^6.1.0",
"typed-emitter": "^1.3.1",
"util": "^0.12.3",
"webpack": "^5.28.0",
"webpack-cli": "^4.5.0"
},
"dependencies": {
"debug": "^4.3.1",
"fast-equals": "^2.0.4",
"mocha-remote-common": "1.8.0",
"ws": "^8.4.2"
},
"eslintConfig": {
"parserOptions": {
"sourceType": "module"
Expand Down
46 changes: 34 additions & 12 deletions packages/client/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,67 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';

import pkg from './package.json';
import pkg from './package.json' assert { type: "json" };

export default [{
input: 'src/node/index.ts',
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' }
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
plugins: [
nodeResolve({
preferBuiltins: true,
}),
commonjs({
include: [
'../mocha/dist/mocha.node.bundle.js',
'../mocha/dist/node/mocha.js',
],
}),
typescript({
module: "esnext",
exclude: ["src/**/*.test.ts"]
tsconfig: "./tsconfig.node.json",
declaration: false,
}),
],
external: ["debug", "fast-deep-equal", "flatted", "mocha-remote-client", "ws"],
external: ["debug", "fast-deep-equal", "flatted", "mocha-remote-client", "ws", "events"],
}, {
input: 'src/browser/index.ts',
output: [
{ file: pkg.browser, format: 'es' }
{ file: pkg.browser, format: 'es', sourcemap: true }
],
plugins: [
nodeResolve({
browser: true,
preferBuiltins: false,
}),
commonjs(),
commonjs({
include: [
'../mocha/dist/browser/mocha.js',
'../../node_modules/events/events.js',
],
}),
typescript({
module: "esnext",
exclude: ["src/**/*.test.ts"]
tsconfig: "./tsconfig.browser.json",
declaration: false,
}),
],
external: ["debug", "fast-deep-equal", "flatted", "mocha-remote-client"],
}, {
input: 'src/index.ts',
output: [
{ file: pkg.types, format: 'es' }
],
plugins: [
nodeResolve({
preferBuiltins: false,
}),
commonjs(),
dts({
tsconfig: "./tsconfig.types.json",
respectExternal: true
}),
],
external: ["debug", "fast-deep-equal", "flatted", "mocha-remote-client", "mocha"],
}];
11 changes: 5 additions & 6 deletions packages/client/src/Client.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { expect } from 'chai';
import * as ws from "ws";
import { WebSocketServer } from "ws";
import * as flatted from "flatted";

import { Client } from './Client';
import { rejects } from 'assert';

const reconnectDelay = 50;

Expand Down Expand Up @@ -159,11 +158,11 @@ describe("Mocha Remote Client", () => {


describe("connecting", () => {
let wss: ws.Server;
let wss: WebSocketServer;
let url: string;

beforeEach(() => {
wss = new ws.Server({ port: 0 });
wss = new WebSocketServer({ port: 0 });
const address = wss.address();
if (typeof address === "object") {
if (address.family === "IPv6") {
Expand All @@ -183,15 +182,15 @@ describe("Mocha Remote Client", () => {
});

it("reconnects until server is up", async () => {
const { port } = wss.address() as ws.AddressInfo;
const { port } = wss.address() as WebSocket.AddressInfo;
// Shut down the server before the client gets a chance to connect
wss.close();
// Start connecting
const client = new Client({ url, reconnectDelay });
// Wait for a couple of attempts
await new Promise(resolve => setTimeout(resolve, reconnectDelay * 2));
// Start the server (using the same port as initially)
wss = new ws.Server({ port });
wss = new WebSocketServer({ port });
await Promise.all([
new Promise(resolve => client.once("connection", resolve)),
new Promise(resolve => wss.once("connection", resolve)),
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Debugger, debug } from "debug";
import debug, { Debugger } from "debug";

export type { Debugger };

Expand Down
17 changes: 17 additions & 0 deletions packages/client/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"rootDir": "src"
},
"include": [
"src/**/*.ts"
]
}
16 changes: 16 additions & 0 deletions packages/client/tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": [
"node"
],
"lib": [
"es2022",
"dom"
]
},
"include": [
"src/browser/*.ts"
],
"exclude": []
}
6 changes: 0 additions & 6 deletions packages/client/tsconfig.build.json

This file was deleted.

8 changes: 8 additions & 0 deletions packages/client/tsconfig.common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"exclude": [
"src/browser/",
"src/node/",
"src/**/*.test.ts"
]
}
18 changes: 5 additions & 13 deletions packages/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"outDir": "dist"
},
"include": [
"src/**/*.ts"
"files": [],
"references": [
{ "path": "./tsconfig.common.json" },
{ "path": "./tsconfig.browser.json" },
{ "path": "./tsconfig.node.json" }
]
}
12 changes: 12 additions & 0 deletions packages/client/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": [
"node"
]
},
"include": [
"src/node/*.ts"
],
"exclude": []
}
7 changes: 7 additions & 0 deletions packages/client/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true
}
}
1 change: 0 additions & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"bugs": "https://github.com/kraenhansen/mocha-remote/issues",
"license": "ISC",
"devDependencies": {
"@types/mocha": "^8.2.2",
"chai": "^4.3.4"
},
"dependencies": {
Expand Down
10 changes: 4 additions & 6 deletions packages/mocha/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
declare module "mocha-remote-mocha" {
import { Context, Runner, Suite, Test, Hook, interfaces } from "mocha";
import type { Interface } from "mocha";
const createStatsCollector: (runner: Runner) => void;
export { Context, Runner, Suite, Test, Hook, interfaces, Interface, createStatsCollector };
}
import { Context, Runner, Suite, Test, Hook, interfaces } from "mocha";
import type { Interface } from "mocha";
const createStatsCollector: (runner: Runner) => void;
export { Context, Runner, Suite, Test, Hook, interfaces, Interface, createStatsCollector };
7 changes: 3 additions & 4 deletions packages/mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
"build": "webpack",
"test": "echo 'No tests to run'"
},
"main": "dist/mocha.node.bundle.js",
"browser": "dist/mocha.browser.bundle.js",
"main": "dist/node/mocha.js",
"browser": "dist/browser/mocha.js",
"types": "index.d.ts",
"author": {
"name": "Kræn Hansen",
"email": "[email protected]",
"url": "https://github.com/kraenhansen"
},
"devDependencies": {
"@types/mocha": "^10.0.3",
"buffer": "^6.0.3",
"mocha": "10.2.0",
"mocha": "10.3.0",
"process": "^0.11.10",
"util": "^0.12.4",
"webpack": "^5.68.0",
Expand Down
Loading
Loading