Skip to content

Commit

Permalink
mocha to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Feb 6, 2024
1 parent f8b98ac commit da444b5
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 120 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@mdx-js/react": "^3.0.0",
"@types/node": "^20.11.16",
"markdownlint": "~0.33.0",
"prettier": "^3.2.5",
"react": "^18.2.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/stylelint-config-ali/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"license": "MIT",
"scripts": {
"test": "mocha ./test/*.test.js"
"test": "rive test"
},
"dependencies": {
"postcss": "^8.4.29",
Expand All @@ -48,7 +48,6 @@
"stylelint": "^16.0.0"
},
"devDependencies": {
"mocha": "^10.2.0",
"stylelint": "^16.0.0",
"stylelint-scss": "^6.0.0"
}
Expand Down
114 changes: 0 additions & 114 deletions packages/stylelint-config-ali/test/rules-validate.test.js

This file was deleted.

87 changes: 87 additions & 0 deletions packages/stylelint-config-ali/test/rules-validate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { readFile } from 'fs/promises';
import { join } from 'path';
import stylelint from 'stylelint';
import config from '../index';

describe('test/rules-validate.test.js', () => {
it('Validate default', async () => {
const result = await stylelint.lint({
config: config as any,
code: await readFile(join(import.meta.dirname, 'fixtures/index.css'), 'utf-8'),
fix: false,
});

if (result && result.errored) {
const filesResult = JSON.parse(result.report || '[]') || [];
filesResult.forEach((fileResult) => {
console.log(fileResult.warnings);
});

expect(filesResult.length).toBeGreaterThan(0);
}
});

it('Validate sass', async () => {
const result = await stylelint.lint({
config: config as any,
code: await readFile(join(import.meta.dirname, 'fixtures/sass-test.scss'), 'utf-8'),
fix: false,
});

if (result && result.errored) {
}
console.log(result.results);
expect(result.results.length).toBeGreaterThan(0);
});

it('Validate less', async () => {
const result = await stylelint.lint({
config: config as any,
code: await readFile(join(import.meta.dirname, 'fixtures/less-test.less'), 'utf-8'),
fix: false,
});

if (result && result.errored) {
const filesResult = JSON.parse(result.report || '[]') || [];
filesResult.forEach((fileResult) => {
console.log(fileResult.warnings);
});

expect(filesResult.length).toBeGreaterThan(0);
}
});

it('Validate miniapp', async () => {
const result = await stylelint.lint({
config: config as any,
code: await readFile(join(import.meta.dirname, 'fixtures/miniapp.acss'), 'utf-8'),
fix: false,
});

if (result && result.errored) {
const filesResult = JSON.parse(result.report || '[]') || [];
filesResult.forEach((fileResult) => {
console.log(fileResult.warnings);
});

expect(filesResult.length).toBe(0);
}
});

it('Validate css-module', async () => {
const result = await stylelint.lint({
config: config as any,
code: await readFile(join(import.meta.dirname, 'fixtures/css-module.scss'), 'utf-8'),
fix: false,
});

if (result && result.errored) {
const filesResult = JSON.parse(result.report || '[]') || [];
filesResult.forEach((fileResult) => {
console.log(fileResult.warnings);
});

expect(filesResult.length).toBe(0);
}
});
});
16 changes: 12 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"moduleResolution": "node16",
"jsx": "react-jsx"
}
"module": "esnext",
"esModuleInterop": true,
"resolveJsonModule": true,
"types": ["node", "rive/globals"],
"lib": ["esnext"],
"allowJs": true,
"checkJs": false,
"skipLibCheck": true,
"moduleResolution": "node",
"isolatedModules": true
},
"exclude": [".rive", "build", "coverage", "dist", "node_modules"]
}

0 comments on commit da444b5

Please sign in to comment.