-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Needs reviews!] Mega test refactor #4378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Less.js test infrastructure to improve maintainability and prepare for a future Less 5.x parser. The main changes involve reorganizing test files, introducing configuration-based test execution, and modernizing the test runner infrastructure.
Key changes:
- Introduces
styles.config.cjsfiles for per-test configuration instead of hardcoded test options - Reorganizes test files into
tests-unit/andtests-config/directories with co-located.cssfiles - Updates test runner to use cosmiconfig for configuration loading and glob patterns for test discovery
Reviewed Changes
Copilot reviewed 59 out of 577 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/test-data/tests-error/eval/styles.config.cjs | Adds config file for eval error tests with strict math/units and JS enabled |
| packages/test-data/tests-config/*/styles.config.cjs | Multiple config files defining test-specific Less compiler options |
| packages/test-data/tests-config/url-args/urls.less | Updates import paths to reflect new directory structure |
| packages/test-data/tests-config/static-urls/urls.* | Updates paths and expected output for static URL tests |
| packages/less/test/less-test.js | Major refactor to support glob patterns, cosmiconfig, and co-located test files |
| packages/less/test/index.js | Replaces nock with needle mocking and updates test configuration to use glob patterns |
| packages/less/test/browser/* | Updates browser test paths to reflect new directory structure |
| packages/less/scripts/postinstall.js | Adds Playwright browser installation script for development environments |
| packages/less/package.json | Updates dependencies and adds postinstall script |
| packages/less/Gruntfile.js | Updates test paths to reflect new directory structure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Seems there is an issue with Windows. I changed: cssPath = path.join(testFolder, 'css', css_name) + '.css';to cssPath = path.join(testFolder, '', css_name) + '.css';in
I cloned your branch and ran the same Slight reduction in coverage. But pretty good given the size of the refactor! This is the command I am using under I'll take a look at the diffs tomorrow, though I am curious as to what your stance on LLM-generated explainer Markdown files like |
Oh, shoot, if they're in there, that was accidental. Sometimes the AI agents create them without asking. Re: coverage -- thanks for putting that in there. Ideally, there wouldn't be a reduction. I'll see if I can add back in test cases for those missing lines. |
Why I did this
As I've mentioned here and there, I've worked on a new Chevrotain-based Less parser for, I dunno, over five years off and on?
I'm finally getting to the part of comparing tests from the existing Less 1.x-4.x parser to what will (if everything goes well) become the Less 5.x+ parser.
However, I ran into a number of things that I wanted to refactor tests for.
styles.config.{cjs, mjs, js, cts, mts, ts}file. That way, the Less 5 test runner could run Less files according to how their configuration settings.less/andcss/folders. This sometimes made updating tests tedious, as you'd have to find the copy for each. Instead, I co-located.csswith their.lessfiles, and grouped many of them into their own folders to make them easier to manage.@less/maintainers @puckowski @iChenLei Let me know if this makes sense, and you have any questions or concerns!