Files
less.js/packages/less/test/browser/runner-browser-options.js
Matthew Dean 432286970a [Needs reviews!] Mega test refactor (#4378)
* Migrate Less to use valid CSS

* Re-organize test structure

* Lots of test refactoring

* More test updates

* Add restructured tests

* WIP

Signed-off-by: Matthew Dean <matthew-dean@users.noreply.github.com>

* More fixes to tests

* More test fixes

* All tests passing

* WIP fix tests

* Finished fixing browser tests

* Improve test coverage

* Add debug tests

* Add back debug tests to show equal test coverage

* Fix browser tests

* More test coverage

* Fix sourcemap absolute path for CI

* More source map normalization for Windows

* Fix source map normalization

* Another attempted fix for Windows

---------

Signed-off-by: Matthew Dean <matthew-dean@users.noreply.github.com>
2025-12-06 11:28:46 -08:00

52 lines
1.6 KiB
JavaScript

var less = {
logLevel: 4,
errorReporting: 'console',
javascriptEnabled: true,
math: 'always'
};
// test inline less in style tags by grabbing an assortment of less files and doing `@import`s
var testFiles = ['charsets/charsets', 'color-functions/basic', 'comments/comments', 'css-3/css-3', 'strings/strings', 'media/media', 'mixins/mixins'],
testSheets = [];
// setup style tags with less and link tags pointing to expected css output
/**
* @todo - generate the node_modules path for this file and in templates
*/
var lessFolder = '../../node_modules/@less/test-data/tests-unit'
var cssFolder = '../../node_modules/@less/test-data/tests-unit'
for (var i = 0; i < testFiles.length; i++) {
var file = testFiles[i],
lessPath = lessFolder + '/' + file + '.less',
cssPath = cssFolder + '/' + file + '.css',
lessStyle = document.createElement('style'),
cssLink = document.createElement('link'),
lessText = '@import "' + lessPath + '";';
lessStyle.type = 'text/less';
lessStyle.id = file;
lessStyle.href = file;
if (lessStyle.styleSheet === undefined) {
lessStyle.appendChild(document.createTextNode(lessText));
}
cssLink.rel = 'stylesheet';
cssLink.type = 'text/css';
cssLink.href = cssPath;
cssLink.id = 'expected-' + file;
var head = document.getElementsByTagName('head')[0];
head.appendChild(lessStyle);
if (lessStyle.styleSheet) {
lessStyle.styleSheet.cssText = lessText;
}
head.appendChild(cssLink);
testSheets[i] = lessStyle;
}