Skip to content

Commit 093e4b7

Browse files
committed
WIP fix tests
1 parent 902a3c6 commit 093e4b7

File tree

6 files changed

+67
-307
lines changed

6 files changed

+67
-307
lines changed

packages/less/Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ module.exports = function(grunt) {
214214
command: "node build/rollup.js --browser --out=./tmp/browser/less.min.js"
215215
},
216216
test: {
217-
command: 'ts-node test/test-es6.ts && node test/index.js'
217+
command: 'npx ts-node test/test-es6.ts && node test/index.js'
218218
},
219219
generatebrowser: {
220220
command: 'node test/browser/generator/generate.js'

packages/less/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"clean": "shx rm -rf ./lib tsconfig.tsbuildinfo",
4545
"compile": "tsc -p tsconfig.build.json",
4646
"dev": "tsc -p tsconfig.build.json -w",
47-
"prepublishOnly": "grunt dist"
47+
"prepublishOnly": "grunt dist",
48+
"postinstall": "node scripts/postinstall.js"
4849
},
4950
"optionalDependencies": {
5051
"errno": "^0.1.1",
@@ -89,8 +90,6 @@
8990
"minimist": "^1.2.0",
9091
"mocha": "^6.2.1",
9192
"mocha-teamcity-reporter": "^3.0.0",
92-
"msw": "~2.11.1",
93-
"nock": "^14.0.10",
9493
"npm-run-all": "^4.1.5",
9594
"performance-now": "^0.2.0",
9695
"phin": "^2.2.3",
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Post-install script for Less.js package
5+
*
6+
* This script installs Playwright browsers only when:
7+
* 1. This is a development environment (not when installed as a dependency)
8+
* 2. We're in a monorepo context (parent package.json exists)
9+
* 3. Not running in CI or other automated environments
10+
*/
11+
12+
const fs = require('fs');
13+
const path = require('path');
14+
const { execSync } = require('child_process');
15+
16+
// Check if we're in a development environment
17+
function isDevelopmentEnvironment() {
18+
// Skip if this is a global install or user config
19+
if (process.env.npm_config_user_config || process.env.npm_config_global) {
20+
return false;
21+
}
22+
23+
// Skip in CI environments
24+
if (process.env.CI || process.env.GITHUB_ACTIONS || process.env.TRAVIS) {
25+
return false;
26+
}
27+
28+
// Check if we're in a monorepo (parent package.json exists)
29+
const parentPackageJson = path.join(__dirname, '../../../package.json');
30+
if (!fs.existsSync(parentPackageJson)) {
31+
return false;
32+
}
33+
34+
// Check if this is the root of the monorepo
35+
const currentPackageJson = path.join(__dirname, '../package.json');
36+
if (!fs.existsSync(currentPackageJson)) {
37+
return false;
38+
}
39+
40+
return true;
41+
}
42+
43+
// Install Playwright browsers
44+
function installPlaywrightBrowsers() {
45+
try {
46+
console.log('🎭 Installing Playwright browsers for development...');
47+
execSync('pnpm exec playwright install', {
48+
stdio: 'inherit',
49+
cwd: path.join(__dirname, '..')
50+
});
51+
console.log('✅ Playwright browsers installed successfully');
52+
} catch (error) {
53+
console.warn('⚠️ Failed to install Playwright browsers:', error.message);
54+
console.warn(' You can install them manually with: pnpm exec playwright install');
55+
}
56+
}
57+
58+
// Main execution
59+
if (isDevelopmentEnvironment()) {
60+
installPlaywrightBrowsers();
61+
}

packages/less/test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ var testMap = [
245245
}
246246
];
247247

248-
// Note: nock mocks are set up globally at the top of the file
248+
// Note: needle mocking is set up globally at the top of the file
249249

250250
testMap.forEach(function(testConfig) {
251251
// For glob patterns, pass lessOptions as the first parameter and patterns as the second

packages/less/test/less-test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ logger.addListener({
2323
module.exports = function(testFilter) {
2424
var path = require('path'),
2525
fs = require('fs'),
26-
clone = require('copy-anything').copy,
27-
nock = require('nock');
26+
clone = require('copy-anything').copy;
2827

2928
var less = require('../');
3029

@@ -377,7 +376,6 @@ module.exports = function(testFilter) {
377376
var includePatterns = [];
378377
var excludePatterns = [];
379378

380-
console.log('DEBUG: Processing glob patterns:', patterns);
381379

382380
patterns.forEach(function(pattern) {
383381
if (pattern.startsWith('!')) {
@@ -399,7 +397,7 @@ module.exports = function(testFilter) {
399397
allFiles = allFiles.concat(files);
400398
});
401399

402-
// Note: nock mocks are set up globally in index.js
400+
// Note: needle mocking is set up globally in index.js
403401

404402
// Process each .less file found
405403
allFiles.forEach(function(filePath) {
@@ -464,11 +462,6 @@ module.exports = function(testFilter) {
464462

465463
var name = getBasename(file, relativePath);
466464

467-
// Debug logging for import-redirect test
468-
if (fullPath.includes('import-redirect')) {
469-
console.log('DEBUG: import-redirect test running, fullPath:', fullPath);
470-
console.log('DEBUG: nock.pendingMocks():', require('nock').pendingMocks());
471-
}
472465

473466
if (oneTestOnly && typeof oneTestOnly === 'string' && !name.includes(oneTestOnly)) {
474467
return;

0 commit comments

Comments
 (0)