test: the component suite has not run since cypress 15, on any machine (#661)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

* test: the component suite has not run since cypress 15, on any machine

Six component spec files -- 334 tests, including the 4,300-line layout suite -- could not
start.  Cypress exited before printing anything, and under its default Electron browser it
did not even do that: it hung at 0% CPU until killed.  Chrome prints the error in seconds,
which is the only reason this was findable.

Three things broke, all of them from the 13.17.0 -> 15.20.0 bump.

`baseUrl: "src"`.  Cypress 15 loads its config with tsx, and tsx honours tsconfig path
resolution.  Cypress requires Node's core `events` module; with that baseUrl the bare
specifier resolves against `src`, and on a case-insensitive filesystem it matches
`src/Events.js`.  That file imports the app, so the whole component tree was required in
Node: JSX in `.js` files, which esbuild will not parse.

This is why CI stayed green while every local run died.  Linux is case-sensitive, `events`
never matched `Events.js`, and it resolved to the built-in.  The baseUrl buys nothing --
there is not one absolute import in the codebase -- so it goes.

`framework: "create-react-app"`.  Cypress 14 removed that dev server; the handler is in the
13.17.0 binary and absent from 15.  The webpack config is handed over explicitly now, taken
from react-scripts so components compile exactly as `npm start` compiles them.  Two things
follow from that: `webpack-dev-server` 5 is a devDependency because Cypress requires 5 and
react-scripts pins 4 (npm nests react-scripts' copy, and the production build is unchanged),
and babel-loader is widened to `cypress/`, which react-scripts does not compile -- the
support file is JSX and was reaching babel with no preset.

The suite ran nowhere.  `cypress run` means e2e -- its specPattern is `cypress/e2e/**` --
and these specs sit beside the components in `src`, so no job has ever executed them.  A
`cypress-component-tests` job runs them now; without it this breaks again in silence.

One test fails the moment the suite can run, and it is mine, from #660: it asserted the URL
column is the widest in the row.  It is not, and never was -- at that width the fixed columns
take ~307px of 400, leaving the URL ~93 against Control's 146.  It shipped green because
nothing could run it.  It asserts a usable remainder instead.

334 component tests pass, 69 suites / 1214 jest tests pass, `npm run build` is clean.

* review: an assertion with a floor, and comments that told the story instead of the rule

The leftover-width test had a lower bound and nothing else, so it passed on any column
wide enough to have padding -- including one that had grown, which is what losing
table-layout: fixed does.  It measures the leftover now: the sized columns are held to
the widths they declare, and the truncating column to exactly what they did not take.

Comments in the config, the CI job and the spec cut back to the rule a reader needs.  The
version history and the measurements are in the PR.
This commit is contained in:
lrnselfreliance 2026-08-12 21:57:07 -06:00 • committed by GitHub
parent 0ae8bd5442
commit 1867382d7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 2377 additions and 250 deletions

View file

@ -168,6 +168,27 @@ jobs:
name: Stop React App
command: pkill -f npm
# Jest tests moved to GitHub Actions (.github/workflows/jest-tests.yml)
# Component specs live under `src/`, so they need `cypress run --component`; the e2e job's
# `cypress run` will not match them. Cypress starts its own dev server, so no `npm start`.
cypress-component-tests:
docker:
- image: cimg/node:20.19-browsers
resource_class: large
steps:
- checkout
- restore_cache:
key: app-browsers-{{ checksum "app/package-lock.json" }}
- run:
name: Install Dependencies
command: cd app && npm install
- run:
name: Install Cypress Binary
command: cd app && npx cypress install
- run:
name: Run Cypress Component Tests
command: cd app && CI=true npx cypress run --component
- store_artifacts:
path: app/cypress/screenshots
cypress-e2e-tests:
docker:
- image: cimg/node:20.19-browsers
@ -229,3 +250,4 @@ workflows:
- react-app-start
# jest-tests moved to GitHub Actions
- cypress-e2e-tests
- cypress-component-tests

View file

@ -1,3 +1,4 @@
const path = require("path");
const { defineConfig } = require("cypress");
module.exports = defineConfig({
@ -14,8 +15,39 @@ module.exports = defineConfig({
},
component: {
devServer: {
framework: "create-react-app",
// Cypress removed its create-react-app framework, so hand it the same webpack config
// `npm start` uses, minus the entry, output and HTML plugins Cypress supplies itself.
framework: "react",
bundler: "webpack",
webpackConfig: () => {
// react-scripts reads both of these at require time.
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
process.env.BABEL_ENV = process.env.BABEL_ENV || 'development';
const config = require('react-scripts/config/webpack.config')('development');
delete config.entry;
delete config.output;
delete config.optimization;
const cypressOwnsThese = [
'HtmlWebpackPlugin', 'InterpolateHtmlPlugin', 'MiniCssExtractPlugin',
'WebpackManifestPlugin', 'ManifestPlugin', 'ModuleNotFoundPlugin',
'ForkTsCheckerWebpackPlugin',
];
config.plugins = (config.plugins || [])
.filter(plugin => !cypressOwnsThese.includes(plugin.constructor.name));
// react-scripts only babel-loads `src`; the JSX support file lives in `cypress/`.
const alsoCompile = [path.resolve(__dirname, 'cypress')];
const widenBabel = (rules) => rules.forEach((rule) => {
if (rule.oneOf) return widenBabel(rule.oneOf);
const loader = String(rule.loader || '');
if (loader.includes('babel-loader') && rule.include) {
rule.include = [].concat(rule.include, alsoCompile);
}
});
widenBabel(config.module.rules);
return config;
},
},
},
});

2531
app/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -64,7 +64,8 @@
"@types/node": "^26.1.2",
"@types/react": "^18.3.17",
"@types/react-dom": "^18.3.5",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"webpack-dev-server": "^5.2.6"
},
"jest": {
"transformIgnorePatterns": [

View file

@ -1510,12 +1510,34 @@ describe('a truncating table fits the width it is given', () => {
const cell = $cell[0];
// It gives up what it cannot show...
expect(cell.scrollWidth, 'the long URL is truncated').to.be.greaterThan(cell.clientWidth);
// ...and it is still the widest column, which is the point of truncating it rather
// than any of the others. A 25em floor made it the widest by overflowing instead.
const others = [...cell.closest('tr').children].filter(td => td !== cell);
others.forEach(td => {
expect(cell.getBoundingClientRect().width, 'the URL keeps the remainder')
.to.be.greaterThan(td.getBoundingClientRect().width);
/*
* ...and it gets precisely what the sized columns did not take. Measured against
* the row rather than against a threshold: a lower bound alone would also pass if
* the column were far too WIDE, which is exactly what losing `table-layout: fixed`
* would do.
*/
const row = cell.closest('tr');
const cells = [...row.children];
const sized = cells
.filter(td => td !== cell)
.reduce((total, td) => total + td.getBoundingClientRect().width, 0);
// The row's box is a few px wider than its cells put together -- the table's own
// borders -- so take that from the row itself rather than allowing a fixed slack.
const chrome = row.getBoundingClientRect().width
- cells.reduce((total, td) => total + td.getBoundingClientRect().width, 0);
const leftover = row.getBoundingClientRect().width - sized - chrome;
expect(leftover, 'the sized columns left something over').to.be.greaterThan(0);
expect(cell.getBoundingClientRect().width, 'and the URL column is exactly that')
.to.be.closeTo(leftover, 1);
// The sized columns took what they asked for, which is what makes the line above
// more than arithmetic: if leftover leaked, one of these would have absorbed it.
const declared = {'col-select': 2.5, 'col-completed': 8, 'col-control-group': 9.5};
const em = parseFloat(getComputedStyle(cell).fontSize);
cells.filter(td => td !== cell).forEach((td, i) => {
const width = Object.values(declared)[i] * em;
expect(td.getBoundingClientRect().width, `sized column ${i} kept its width`)
.to.be.closeTo(width, 2);
});
});
});

View file

@ -14,8 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "src"
"jsx": "react-jsx"
},
"include": ["src"],
"exclude": ["node_modules"]