Skip to content

Commit

Permalink
Migrated from mocha to vitest (#393)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Iden <[email protected]>
  • Loading branch information
jonah-iden authored Nov 6, 2023
1 parent 727c224 commit 6d43db2
Show file tree
Hide file tree
Showing 49 changed files with 627 additions and 399 deletions.
38 changes: 11 additions & 27 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,25 @@
"version": "0.2.0",
"configurations": [
{
"name": "Mocha: Test Current File",
"name": "Vitest: Run All",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/.bin/ts-mocha",
"args": [
"${file}",
"--no-timeouts"
],
"env": {
"TS_NODE_PROJECT": "${workspaceRoot}/tsconfig.json"
},
"sourceMaps": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "--no-color", "--no-coverage", "--no-watch"],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
"console": "integratedTerminal",
},
{
"name": "Mocha: Test All",
"name": "Vitest: Run Selected File",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/.bin/ts-mocha",
"args": [
"-p",
"tsconfig.json",
"**/src/**/*.spec.ts",
],
"env": {
"NODE_ENV": "test"
},
"sourceMaps": true,
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
"console": "integratedTerminal",
},
{
"name": "Examples Server",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"prepare": "lerna run prepare",
"clean": "lerna run clean",
"build": "lerna run build",
"test": "lerna run test",
"test": "vitest run",
"coverage": "vitest run --coverage",
"publish:prepare": "lerna version --ignore-scripts --yes --no-push",
"publish:latest": "lerna publish from-git --yes --no-push",
"publish:next": "SHA=$(git rev-parse --short HEAD) && lerna publish preminor --exact --canary --preid next.${SHA} --dist-tag next --no-git-reset --no-git-tag-version --no-push --ignore-scripts --yes --no-verify-access"
Expand All @@ -20,7 +21,9 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.5",
"semver": "^7.5.4",
"typescript": "~5.2.2"
"typescript": "~5.2.2",
"@vitest/coverage-v8": "~0.34.6",
"vitest": "~0.34.6"
},
"workspaces": [
"packages/*",
Expand Down
12 changes: 2 additions & 10 deletions packages/sprotty-elk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,13 @@
"optionalDependencies": {
"inversify": "^6.0.1"
},
"devDependencies": {
"@types/chai": "^4.3.6",
"@types/mocha": "^10.0.2",
"@types/node": "^18.15.0",
"chai": "^4.3.10",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"test": "vitest run --config ../../vite.config.ts",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\"",
"test": "ts-mocha \"./src/**/*.spec.?(ts|tsx)\""
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\""
},
"files": [
"lib",
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-elk/src/elk-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import 'reflect-metadata';
import 'mocha';
import { expect } from 'chai';
import { expect, describe, it } from 'vitest';
import { Container } from 'inversify';
import ElkConstructor from 'elkjs/lib/elk.bundled';
import { SCompartment, SEdge, SGraph, SNode, SPort } from 'sprotty-protocol/lib/model';
Expand Down
11 changes: 3 additions & 8 deletions packages/sprotty-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
"url": "https://github.com/eclipse-sprotty/sprotty",
"directory": "packages/sprotty-protocol"
},
"devDependencies": {
"@types/mocha": "^10.0.2",
"chai": "^4.3.10",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0"
},

"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"test": "vitest run --config ../../vite.config.ts",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\"",
"test": "ts-mocha \"./src/**/*.spec.?(ts|tsx)\""
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*)\""
},
"files": [
"lib",
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-protocol/src/diagram-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from 'chai';
import { expect, describe, it } from 'vitest';
import { Action, ComputedBoundsAction, RequestBoundsAction, RequestModelAction, SetModelAction } from './actions';
import { DiagramServer } from './diagram-server';
import { BoundsAware, SModelRoot } from './model';
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-protocol/src/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { SModelRoot } from './model';
import { SModelIndex } from './utils/model-utils';

Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-protocol/src/utils/async.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Deferred } from "./async";
import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';

describe('Deferred', () => {
it('is in "unresolved" state after construction', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty-protocol/src/utils/geometry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { almostEquals, Bounds, angleBetweenPoints, Point } from "./geometry";

describe('almostEquals', () => {
Expand Down
10 changes: 3 additions & 7 deletions packages/sprotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,16 @@
"@types/chai": "^4.3.6",
"@types/file-saver": "^2.0.5",
"@types/jsdom": "^21.1.3",
"@types/mocha": "^10.0.2",
"chai": "^4.3.10",
"jsdom": "^22.1.0",
"mocha": "^10.2.0",
"snabbdom-to-html": "^7.1.0",
"ts-mocha": "^10.0.0"
"snabbdom-to-html": "^7.1.0"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib artifacts",
"build": "tsc -p ./tsconfig.json && yarn run lint",
"test": "vitest run --config ../../vite.config.ts",
"watch": "tsc -w -p ./tsconfig.json",
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*|test-helper.ts)\"",
"test": "ts-mocha \"./src/**/*.spec.?(ts|tsx)\""
"lint": "eslint -c ../../configs/.eslintrc.js \"src/**/!(*.spec.ts*|test-helper.ts)\""
},
"files": [
"lib",
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/actions/action-dispatcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import 'reflect-metadata';
import 'mocha';
import { expect } from "chai";
import { expect, describe, it } from 'vitest';;
import { Container, injectable, interfaces } from "inversify";
import { Action, RedoAction, RejectAction, RequestModelAction, SetModelAction, UndoAction } from 'sprotty-protocol/lib/actions';
import { Bounds } from 'sprotty-protocol/lib/utils/geometry';
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/animations/easing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { easeInOut } from "./easing";

describe('easing', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import "reflect-metadata";
import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { Container, injectable, inject } from "inversify";
import { TYPES } from "../types";
import { configureCommand, CommandActionHandlerInitializer } from "./command-registration";
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/commands/command-stack.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import "reflect-metadata";
import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { Container, injectable } from "inversify";
import { TYPES } from "../types";
import defaultModule from "../di.config";
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/features/initialize-canvas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import "reflect-metadata";
import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { CommandExecutionContext } from '../commands/command';
import { InitializeCanvasBoundsAction, InitializeCanvasBoundsCommand } from './initialize-canvas';
import { SModelRootImpl } from "../model/smodel";
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/features/set-model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import 'reflect-metadata';
import 'mocha';
import { expect } from 'chai';
import { expect, describe, it } from 'vitest';
import { Container } from 'inversify';
import { TYPES } from '../types';
import { SModelElementImpl } from '../model/smodel';
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/model/smodel-factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import 'reflect-metadata';
import 'mocha';
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { Container } from 'inversify';
import { TYPES } from '../types';
import { ModelIndexImpl, SChildElementImpl } from './smodel';
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/model/smodel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { SChildElementImpl, ModelIndexImpl, SModelRootImpl } from './smodel';

describe('SModelRootImpl', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
/** @jsx svg */
import { svg } from '../../lib/jsx';

import "mocha";
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { CssClassPostprocessor } from './css-class-postprocessor';
import { SModelElementImpl } from '../model/smodel';

Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/views/thunk-view.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
/** @jsx svg */
import { svg } from '../../lib/jsx';

import 'mocha';
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { init } from "snabbdom";
import { SModelElementImpl } from "../model/smodel";
import { ModelRenderer } from './viewer';
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/base/views/view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
********************************************************************************/

import 'reflect-metadata';
import 'mocha';
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { Container } from 'inversify';
import { TYPES } from '../types';
import { EMPTY_ROOT, SModelFactory } from '../model/smodel-factory';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { expect } from 'chai';
import { Container } from 'inversify';
import 'mocha';
import 'reflect-metadata';

import { expect, describe, it } from 'vitest';
import { AnimationFrameSyncer } from '../../base/animations/animation-frame-syncer';
import { CommandExecutionContext } from '../../base/commands/command';
import defaultModule from '../../base/di.config';
Expand Down
5 changes: 3 additions & 2 deletions packages/sprotty/src/features/bounds/hbox-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from "chai";
import 'reflect-metadata';

import { expect, describe, it } from 'vitest';
import { SModelElementImpl, SParentElementImpl } from '../../base/model/smodel';
import { createFeatureSet } from '../../base/model/smodel-factory';
import { SNodeImpl, SLabelImpl } from '../../graph/sgraph';
Expand Down
4 changes: 2 additions & 2 deletions packages/sprotty/src/features/bounds/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Layouter {
@inject(TYPES.LayoutRegistry) protected layoutRegistry: LayoutRegistry;
@inject(TYPES.ILogger) protected logger: ILogger;

layout(element2boundsData: Map<SModelElementImpl​​ , BoundsData>) {
layout(element2boundsData: Map<SModelElementImpl, BoundsData>) {
new StatefulLayouter(element2boundsData, this.layoutRegistry, this.logger).layout();
}
}
Expand All @@ -61,7 +61,7 @@ export class StatefulLayouter {

private toBeLayouted: (SParentElementImpl & LayoutContainer)[];

constructor(private readonly element2boundsData: Map<SModelElementImpl​​ , BoundsData>,
constructor(private readonly element2boundsData: Map<SModelElementImpl, BoundsData>,
private readonly layoutRegistry: LayoutRegistry,
public readonly log: ILogger) {
this.toBeLayouted = [];
Expand Down
3 changes: 1 addition & 2 deletions packages/sprotty/src/features/bounds/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from "chai";
import { expect, describe, it } from 'vitest';
import { SModelRootImpl } from '../../base/model/smodel';
import { SShapeElementImpl, getAbsoluteBounds } from './model';

Expand Down
5 changes: 3 additions & 2 deletions packages/sprotty/src/features/bounds/stack-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from "chai";
import 'reflect-metadata';

import { expect, describe, it } from 'vitest';
import { SModelElementImpl, SParentElementImpl } from '../../base/model/smodel';
import { createFeatureSet } from '../../base/model/smodel-factory';
import { SNodeImpl, SLabelImpl } from '../../graph/sgraph';
Expand Down
4 changes: 2 additions & 2 deletions packages/sprotty/src/features/bounds/vbox-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from "chai";
import 'reflect-metadata';
import { expect, describe, it } from 'vitest';
import { SModelElementImpl, SParentElementImpl } from '../../base/model/smodel';
import { createFeatureSet } from '../../base/model/smodel-factory';
import { SNodeImpl, SLabelImpl } from '../../graph/sgraph';
Expand Down
5 changes: 3 additions & 2 deletions packages/sprotty/src/features/bounds/views.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import 'mocha';
import { expect } from "chai";
import 'reflect-metadata';

import { expect, describe, it } from 'vitest';
import { IViewArgs, RenderingContext } from '../../base/views/view';
import { ViewportRootElementImpl } from '../viewport/viewport-root';
import { SShapeElementImpl } from './model';
Expand Down
Loading

0 comments on commit 6d43db2

Please sign in to comment.