Skip to content

Commit

Permalink
chore: replace mocha by vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomontalbano committed Mar 3, 2024
1 parent 848bcde commit 3c82690
Show file tree
Hide file tree
Showing 39 changed files with 1,636 additions and 1,417 deletions.
10 changes: 1 addition & 9 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
commonjs: true,
es6: true,
node: true,
mocha: true,
},
settings: {
'import/resolver': {
Expand All @@ -15,15 +14,9 @@ module.exports = {
extends: [
'airbnb-base',
],
plugins: [
'chai-friendly',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
expect: true,
sinon: true,
chai: true,
},
parserOptions: {
ecmaVersion: 2020,
Expand All @@ -32,9 +25,8 @@ module.exports = {
indent: ['error', 4, {
SwitchCase: 1,
}],
'max-len': ['error', 140],
'max-len': ['error', 160],
'no-unused-expressions': 'off',
'chai-friendly/no-unused-expressions': 'error',
'arrow-body-style': 'off',
'import/extensions': [
'error',
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# act -j test --container-architecture linux/amd64 -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-latest

name: Test

on:
Expand All @@ -14,8 +16,7 @@ jobs:

strategy:
matrix:
node: [18.x, 20.x, 21.x]
# node: [18.0.0, 18.x, 20.x, 21.x]
node: [18.0.0, 18.x, 20.x, 21.x]

steps:
- name: Checkout 🛎️
Expand Down
10 changes: 0 additions & 10 deletions .mocharc.integration.json

This file was deleted.

10 changes: 0 additions & 10 deletions .mocharc.json

This file was deleted.

12 changes: 0 additions & 12 deletions .nycrc

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"eslint.validate": ["typescript", "typescriptreact"],
"eslint.lintTask.options": ". --ignore-pattern=node_modules --ignore-pattern=/output --ignore-pattern=dist --ext .js,.ts",
"editor.rulers": [
140
160
],
"javascript.preferences.importModuleSpecifierEnding": "js",
}
33 changes: 10 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"clean": "rm -rf node_modules/ output/ */*/node_modules */*/dist */*/tsconfig.tsbuildinfo",
"build": "tsc --build packages/**/tsconfig.json",
"lint": "yarn build && eslint . --ignore-pattern=node_modules --ignore-pattern=output --ignore-pattern=dist --ext .js,.jsx,.ts",
"test": "yarn build && TS_NODE_PROJECT='./tsconfig.mocha.json' mocha",
"test:integration": "yarn build && TS_NODE_PROJECT='./tsconfig.mocha.json' mocha --config .mocharc.integration.json",
"test:watch": "yarn dlx nodemon -e js,mjs,ts --exec yarn test --reporter=dot",
"coverage": "c8 yarn test --reporter=dot",
"coverage:watch": "yarn dlx nodemon -e js,mjs,ts --exec yarn coverage",
"website:start": "yarn build && yarn workspace @figma-export/website dev",
"test": "vitest run --exclude '**/integration.test.ts'",
"test:integration": "vitest watch integration.test.ts",
"test:watch": "vitest watch --exclude '**/integration.test.ts'",
"coverage": "vitest run --coverage --exclude '**/integration.test.ts'",
"coverage:watch": "vitest watch --coverage --exclude '**/integration.test.ts'",
"website:dev": "yarn build && yarn workspace @figma-export/website dev",
"website:build": "yarn build && yarn workspace @figma-export/website build",
"website:serve": "yarn dlx serve packages/website/dist/",
"website:start": "yarn dlx serve packages/website/dist/",
"upgrade:major": "npx npm-check-updates -ws --root -u",
"upgrade:minor": "yarn upgrade:major --target minor",
"ls-engines": "yarn dlx ls-engines",
Expand All @@ -41,36 +41,23 @@
]
},
"devDependencies": {
"@types/chai": "~4.3.12",
"@types/chai-as-promised": "^7.1.8",
"@types/chai-things": "0.0.38",
"@types/mocha": "~10.0.6",
"@types/node": "~20.11.20",
"@types/sinon": "~17.0.3",
"@types/sinon-chai": "~3.2.12",
"@typescript-eslint/eslint-plugin": "~7.0.2",
"@typescript-eslint/parser": "~7.0.2",
"c8": "^9.1.0",
"chai": "~5.1.0",
"chai-as-promised": "^7.1.1",
"chai-things": "~0.2.0",
"@vitest/coverage-istanbul": "^1.3.1",
"eslint": "~8.57.0",
"eslint-config-airbnb": "~19.0.4",
"eslint-plugin-chai-friendly": "~0.7.4",
"eslint-plugin-import": "~2.29.1",
"husky": "^9.0.11",
"lerna": "^8.1.2",
"lerna-changelog": "~2.2.0",
"lint-staged": "~15.2.2",
"ls-engines": "^0.9.1",
"mocha": "~10.3.0",
"nock": "~13.5.3",
"npm-check-updates": "^16.14.15",
"sinon": "~17.0.1",
"sinon-chai": "~3.7.0",
"testdouble": "^3.20.1",
"ts-node": "~10.9.2",
"typescript": "~5.3.3"
"typescript": "~5.3.3",
"vitest": "^1.3.1"
},
"engines": {
"node": ">= 18"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { expect, describe, it } from 'vitest';
import { asArray, requirePackages } from './utils.js';

describe('Utils', () => {
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'chai';
import { expect, describe, it } from 'vitest';

import { components as exportComponents } from './lib/export-components.js';
import { styles as exportStyles } from './lib/export-styles.js';

describe('@figma-export/core', () => {
it('Export components', async () => {
it('Export components', { timeout: 60 * 1000 }, async () => {
const pageNodes = await exportComponents({
fileId: 'fzYhvQpqwhZDUImRz431Qo',
token: process.env.FIGMA_TOKEN ?? '',
Expand All @@ -24,9 +24,9 @@ describe('@figma-export/core', () => {
'figma/logo/main (bright)',
'Type=Icon only, Visible=No',
]);
}).timeout(60 * 1000);
});

it('Export components (only instances)', async () => {
it('Export components (only instances)', { timeout: 60 * 1000 }, async () => {
const pageNodes = await exportComponents({
fileId: 'fzYhvQpqwhZDUImRz431Qo',
token: process.env.FIGMA_TOKEN ?? '',
Expand All @@ -43,9 +43,9 @@ describe('@figma-export/core', () => {
expect(pageNodes[0].components.map((c) => c.name)).to.eql([
'figma/logo/main (bright) - INSTANCE',
]);
}).timeout(60 * 1000);
});

it('Export styles', async () => {
it('Export styles', { timeout: 60 * 1000 }, async () => {
const styles = await exportStyles({
fileId: 'fzYhvQpqwhZDUImRz431Qo',
token: process.env.FIGMA_TOKEN ?? '',
Expand All @@ -64,5 +64,5 @@ describe('@figma-export/core', () => {
visible: true,
},
]);
}).timeout(60 * 1000);
});
});
File renamed without changes.
Loading

0 comments on commit 3c82690

Please sign in to comment.