Skip to content

Commit

Permalink
[test] Restore the t command (mui#40430)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored and mnajdova committed Jan 9, 2024
1 parent 488ca3f commit e88cb88
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
"size:snapshot": "node --max-old-space-size=4096 ./scripts/sizeSnapshot/create",
"size:why": "pnpm size:snapshot --analyze",
"start": "pnpm install && pnpm docs:dev",
"t": "node test/cli.js",
"test": "pnpm eslint && pnpm typescript && pnpm test:coverage",
"test": "node scripts/test.mjs",
"tc": "node test/cli.js",
"test:extended": "pnpm eslint && pnpm typescript && pnpm test:coverage",
"test:coverage": "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": "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": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=html mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
Expand Down
34 changes: 34 additions & 0 deletions scripts/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-console */
import { spawn } from 'node:child_process';
import chalk from 'chalk';

/*
This script ensures that we can use the same commands to run tests
when using pnpm as when using Yarn.
It enables to run `pnpm test` (or `pnpm t`) without any arguments, to run all tests,
or `pnpm test <test-name>` (or `pnpm t <test-name>`) to run a subset of tests in watch mode.
See https://github.com/mui/material-ui/pull/40430 for more context.
*/

if (process.argv.length < 3) {
console.log('Running ESLint, type checker, and unit tests...');
spawn('pnpm', ['test:extended'], {
shell: true,
stdio: ['inherit', 'inherit', 'inherit'],
});
} else {
console.log('Running selected tests in watch mode...');
console.log(
chalk.yellow(
'Note: run `pnpm tc` to have a better experience (and be able to pass in additional parameters).',
),
);

console.log('cmd', ['tc', ...process.argv.slice(2)]);

spawn('pnpm', ['tc', ...process.argv.slice(2)], {
shell: true,
stdio: ['inherit', 'inherit', 'inherit'],
});
}

0 comments on commit e88cb88

Please sign in to comment.