test(migrate): migrate test tooling from chai + mocha to vitest (#203)

* test(migrate): migrate test tooling from chai + mocha to vitest

* fix: fix wrong vitest cli command for watch
This commit is contained in:
Fazza Razaq Amiarso 2022-11-21 19:15:58 +07:00 committed by GitHub
parent fcde7eb14f
commit 59d76181db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 1152 additions and 1865 deletions

2950
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,32 +24,29 @@
"ui"
],
"scripts": {
"test": "mocha --parallel --timeout 15000",
"test:watch": "mocha --watch --parallel --timeout 15000",
"test": "vitest run",
"test:watch": "vitest",
"format": "prettier -w .",
"lint": "eslint . --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js",
"check": "astro check && tsc --noEmit"
},
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.5.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"common": "file:packages/common",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.7.0",
"typescript": "^4.8.3"
"typescript": "^4.8.3",
"vitest": "^0.25.2"
},
"peerDependencies": {
"astro": "^1.5.0"

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { describe, beforeEach, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('Dropdown.astro test', () => {
let component;

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import { beforeEach, describe, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('Field.astro test', () => {
let component;

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import { beforeEach, describe, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('FieldSet.astro test', () => {
let component;

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { describe, beforeEach, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('Form.astro test', () => {
let component;

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { describe, beforeEach, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('RadioGroup.astro test', () => {
let component;

View file

@ -1,7 +1,6 @@
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { describe, beforeEach, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
import { cleanString } from './utils';
describe('TextArea.astro test', () => {
let component;

View file

@ -1,3 +1,3 @@
export function cleanString(str) {
export function cleanString(str: string) {
return typeof str !== 'string' ? '' : str.replace(/\s/g, '');
}

View file

@ -0,0 +1,5 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {},
});

View file

@ -22,32 +22,29 @@
"astro-component"
],
"scripts": {
"test": "mocha --parallel --timeout 15000",
"test:watch": "mocha --watch --parallel --timeout 15000",
"test": "vitest run",
"test:watch": "vitest",
"format": "prettier -w .",
"lint": "eslint . --ext .ts,.js",
"lint:fix": "eslint --fix . --ext .ts,.js",
"check": "astro check && tsc --noEmit"
},
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/eslint": "^8.4.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.7.18",
"@types/prettier": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"astro": "^1.5.0",
"astro-component-tester": "^0.6.0",
"chai": "^4.3.6",
"common": "file:packages/common",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"prettier-plugin-astro": "^0.7.0",
"typescript": "^4.8.3"
"typescript": "^4.8.3",
"vitest": "^0.25.2"
},
"peerDependencies": {
"astro": "^1.5.0"

View file

@ -1,5 +1,4 @@
import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { describe, beforeEach, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
describe('Example Tests', () => {

View file

@ -0,0 +1,5 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {},
});