Skip to content

Commit

Permalink
[core] Migrate test runner to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
brijeshb42 committed May 10, 2024
1 parent 6c51d74 commit 42bc0d6
Show file tree
Hide file tree
Showing 60 changed files with 669 additions and 323 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
/test/bundling/fixtures/gatsby/.cache
/test/bundling/fixtures/gatsby/public
/test/bundling/fixtures/gatsby/public
/test/karma.conf.js
/test/karma.conf.profile.js
/test/regressions/**/*
/tmp
.next
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = {
'react/forbid-prop-types': 'off', // Too strict, no time for that
'react/jsx-curly-brace-presence': 'off', // broken
// airbnb is using .jsx
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.tsx'] }],
// Prefer <React.Fragment> over <>.
'react/jsx-fragments': ['error', 'element'],
// Enforces premature optimization
Expand Down Expand Up @@ -209,6 +209,7 @@ module.exports = {
'*.test.js',
'*.test.ts',
'*.test.tsx',
'*.test.jsx',
],
extends: ['plugin:mocha/recommended'],
rules: {
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
/.eslintcache
/.nyc_output
/benchmark/**/dist
/coverage
/coverage/
/html/
/docs/.env.local
/docs/export
/docs/pages/playground/
Expand Down
9 changes: 0 additions & 9 deletions apps/pigment-css-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,5 @@
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"eslint": "^8.57.0"
},
"nx": {
"targets": {
"preview": {
"dependsOn": [
"^build"
]
}
}
}
}
14 changes: 0 additions & 14 deletions apps/pigment-css-vite-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,5 @@
"postcss-combine-media-query": "^1.0.1",
"vite": "5.2.11",
"vite-plugin-pages": "^0.32.1"
},
"nx": {
"targets": {
"preview": {
"dependsOn": [
"^build"
]
},
"dev": {
"dependsOn": [
"^build"
]
}
}
}
}
13 changes: 12 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"extends": "nx/presets/npm.json",
"targetDefaults": {
"copy-license": {
"cache": true,
"outputs": ["{projectRoot}/LICENSE"]
},
"build": {
Expand All @@ -13,6 +12,18 @@
},
"preview": {
"dependsOn": ["^build"]
},
"test": {
"cache": false,
"dependsOn": ["build"]
},
"test:update": {
"cache": false,
"dependsOn": ["build"]
},
"test:ci": {
"cache": false,
"dependsOn": ["build"]
}
}
}
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@
"test": "node scripts/test.mjs",
"tc": "node test/cli.js",
"test:extended": "pnpm eslint && pnpm typescript && pnpm test:coverage",
"test:coverage": "pnpm build && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=text mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"test:coverage:ci": "pnpm build && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"test:coverage:html": "pnpm build && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=html mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"test:regressions": "cross-env NODE_ENV=production pnpm test:regressions:build && concurrently --success first --kill-others \"pnpm test:regressions:run\" \"pnpm test:regressions:server\"",
"test:regressions:build": "webpack --config test/regressions/webpack.config.js",
"test:regressions:dev": "concurrently \"pnpm test:regressions:build --watch\" \"pnpm test:regressions:server\"",
"test:regressions:run": "mocha --config test/regressions/.mocharc.js --delay 'test/regressions/**/*.test.js'",
"test:regressions:server": "serve test/regressions -p 5001",
"test:unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"test:coverage": "nx run-many -t test:ci",
"test:coverage:ci": "NODE_ENV=test nx run-many -t test:ci",
"test:coverage:html": "NODE_ENV=test nx run-many -t test:ci:html",
"test:unit": "nx run-many -t test",
"test:argos": "node ./scripts/pushArgos.mjs",
"typescript": "tsc -b tsconfig.typecheck.json",
"typescript:ci": "lerna run --concurrency 3 --no-bail --no-sort typescript",
Expand Down Expand Up @@ -65,14 +60,17 @@
"@next/eslint-plugin-next": "^14.1.4",
"@octokit/rest": "^20.1.0",
"@playwright/test": "1.43.0",
"@testing-library/react": "^15.0.7",
"@testing-library/jest-dom": "^6.4.5",
"@types/fs-extra": "^11.0.4",
"@types/lodash": "^4.17.0",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.30",
"@types/react": "^18.2.74",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-module-resolver": "^5.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
Expand Down Expand Up @@ -100,7 +98,6 @@
"lerna": "^8.1.2",
"lodash": "^4.17.21",
"markdownlint-cli2": "^0.13.0",
"mocha": "^10.4.0",
"nx": "^18.2.3",
"nyc": "^15.1.0",
"postcss-styled-syntax": "^0.6.4",
Expand All @@ -117,6 +114,7 @@
"tsx": "^4.7.2",
"typescript": "^5.4.4",
"unist-util-visit": "^2.0.3",
"vitest": "^1.6.0",
"yargs": "^17.7.2"
},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@typescript-eslint/parser": "^7.5.0"
},
"scripts": {
"test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/eslint-plugin-material-ui/**/*.test.js' --timeout 3000"
"test": "echo \"No tests here\""
},
"license": "MIT"
}
2 changes: 2 additions & 0 deletions packages/pigment-css-react/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/processors/
/utils/
LICENSE
/html/
/coverage/
39 changes: 6 additions & 33 deletions packages/pigment-css-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"watch": "tsup --watch --clean false",
"copy-license": "node ../../scripts/pigment-license.mjs",
"build": "tsup",
"test": "cd ../../ && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=text mocha 'packages/pigment-css-react/**/*.test.{js,ts,tsx}'",
"test:update": "cd ../../ && cross-env NODE_ENV=test UPDATE_FIXTURES=true mocha 'packages/pigment-css-react/**/*.test.{js,ts,tsx}'",
"test:ci": "cd ../../ && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --report-dir=./coverage/pigment-css-react mocha 'packages/pigment-css-react/**/*.test.{js,ts,tsx}'",
"test": "vitest run",
"test:update": "UPDATE_FIXTURES=true vitest run",
"test:ci": "vitest run --coverage --reporter=html --coverage.reportsDirectory=./coverage",
"typecheck": "tsc --noEmit -p ."
},
"dependencies": {
Expand Down Expand Up @@ -55,17 +55,19 @@
},
"devDependencies": {
"@babel/plugin-syntax-jsx": "^7.24.1",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/babel__core": "^7.20.5",
"@types/babel__helper-module-imports": "^7.18.3",
"@types/babel__helper-plugin-utils": "^7.10.3",
"@types/chai": "^4.3.16",
"@types/cssesc": "^3.0.2",
"@types/lodash": "^4.17.1",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.31",
"@types/prop-types": "^15.7.12",
"@types/react": "^18.3.1",
"@types/stylis": "^4.2.6",
"@vitejs/plugin-react": "^4.2.1",
"chai": "^4.4.1",
"prettier": "^3.2.5",
"prop-types": "^15.8.1",
Expand Down Expand Up @@ -149,34 +151,5 @@
"require": "./build/RtlProvider.js",
"default": "./build/RtlProvider.js"
}
},
"nx": {
"targets": {
"test": {
"cache": false,
"dependsOn": [
"build"
]
},
"test:update": {
"cache": false,
"dependsOn": [
"build"
]
},
"test:ci": {
"cache": false,
"dependsOn": [
"build"
]
},
"build": {
"outputs": [
"{projectRoot}/build",
"{projectRoot}/processors",
"{projectRoot}/utils"
]
}
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/pigment-css-react/tests/Box.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Box } from '@pigment-css/react/Box';
import Box from '../src/Box';

export function App() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.sd5jss7 {
.s102a5ob {
margin: 0;
margin-block: 1rem;
padding: 0;
Expand All @@ -7,7 +7,7 @@
flex-direction: column;
gap: 0.5rem;
}
.sk625fs {
.s22pi4e {
display: flex;
flex-direction: column;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export function App(props) {
as: 'ul',
'aria-label': props.label,
children: 'Hello Box',
..._sx('sd5jss7', {}),
..._sx('s102a5ob', {}),
});
}
function App2(props) {
return /*#__PURE__*/ _jsxDEV(
Box,
{
children: 'Test',
..._sx2('sk625fs', {}),
..._sx2('s22pi4e', {}),
},
void 0,
false,
Expand Down
4 changes: 2 additions & 2 deletions packages/pigment-css-react/tests/Box/fixtures/box.output.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.bc1d15y {
color: var(--bc1d15y-0);
.b1akj7oz {
color: var(--b1akj7oz-0);
margin: 0;
margin-block: 1rem;
padding: 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/pigment-css-react/tests/Box/fixtures/box.output.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export function App(props) {
aria-label={props.label}
{..._sx(
{
className: 'bc1d15y',
className: 'b1akj7oz',
vars: {
'bc1d15y-0': [props.color, false],
'b1akj7oz-0': [props.color, false],
},
},
{},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.c1pj8glw {
.ccs6o9u {
color: red;
font-size: 3rem;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const cls1 = 'c1pj8glw';
const cls1 = 'ccs6o9u';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@keyframes gpsum18 {
@keyframes g14ms9lx {
0% {
background: red;
}
Expand All @@ -9,7 +9,7 @@
background: blue;
}
}
@keyframes g1t1dgxp {
@keyframes gz01um {
0% {
background: red;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const gradientKeyframe = 'gpsum18';
const gradientKeyframe2 = 'g1t1dgxp';
const gradientKeyframe = 'g14ms9lx';
const gradientKeyframe2 = 'gz01um';
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@keyframes rr2uptz {
@keyframes r6toupf {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0deg);
}
}
@keyframes r1dngkim {
@keyframes rwg7boy {
from {
transform: rotate(360deg);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const rotateKeyframe = 'rr2uptz';
const rotateKeyframe2 = 'r1dngkim';
const rotateKeyframe = 'r6toupf';
const rotateKeyframe2 = 'rwg7boy';
Loading

0 comments on commit 42bc0d6

Please sign in to comment.