Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.0/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
"files": {
"includes": [
"src/**",
Expand Down
8 changes: 4 additions & 4 deletions scripts/extractVsix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ const dirname = fileURLToPath(new URL('.', import.meta.url));

const vsix = fs
.readdirSync(path.join(dirname, '..'), {
withFileTypes: true,
withFileTypes: true
})
.filter((f) => f.name.startsWith('mocha-vscode') && f.name.endsWith('.vsix'));
.filter(f => f.name.startsWith('mocha-vscode') && f.name.endsWith('.vsix'));

if (vsix.length > 1) {
console.error('Multiple VSIX files found, cannot decide which is the one for testing');
process.exit(1);
}

const tempDir = process.env.TEST_TEMP ?? path.join(dirname, '..', 'tmp')
const tempDir = process.env.TEST_TEMP ?? path.join(dirname, '..', 'tmp');
const extensionDir = path.join(tempDir, 'vsix');
await fs.promises.rm(extensionDir, { recursive: true, force: true });
await fs.promises.mkdir(extensionDir, { recursive: true });

await extract(path.join(vsix[0].parentPath, vsix[0].name), {
dir: extensionDir,
dir: extensionDir
});
8 changes: 3 additions & 5 deletions scripts/prerelease.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import { fileURLToPath } from 'node:url';

console.log('Preparing for extension publish');

const gitHubContext = process.env.GITHUB_CONTEXT
? JSON.parse(process.env.GITHUB_CONTEXT)
: undefined;
const gitHubContext = process.env.GITHUB_CONTEXT ? JSON.parse(process.env.GITHUB_CONTEXT) : undefined;

const dirname = fileURLToPath(new URL('.', import.meta.url));

Expand All @@ -39,7 +37,7 @@ if (gitHubContext) {

if (packageJson.version !== tag.slice(1).split('-')[0]) {
console.error(
`Git Tag '${tag}' does not match version in package.json '${packageJson.version}', please correct it!`,
`Git Tag '${tag}' does not match version in package.json '${packageJson.version}', please correct it!`
);
process.exit(1);
}
Expand All @@ -50,7 +48,7 @@ if (gitHubContext) {

packageJson['mocha-vscode'] = {
version: semVer,
date: new Date().toISOString(),
date: new Date().toISOString()
};

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2).replaceAll('\r\n', '\n'));
10 changes: 3 additions & 7 deletions scripts/tsnocheck.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { fileURLToPath } from 'node:url';
const dirname = fileURLToPath(new URL('.', import.meta.url));
const reporter = path.join(dirname, '../out/reporter');
const files = (await fs.promises.readdir(reporter)).filter(f => f.endsWith('.js')).map(f => `${reporter}/${f}`);
for(const f of files) {
await fs.promises.writeFile(
f,
'// @ts-nocheck\n' +
(await fs.promises.readFile(f, 'utf-8'))
)
}
for (const f of files) {
await fs.promises.writeFile(f, '// @ts-nocheck\n' + (await fs.promises.readFile(f, 'utf-8')));
}
4 changes: 1 addition & 3 deletions src/reporter/fullJsonStreamReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ module.exports = class FullJsonStreamReporter {
runner.on(constants.EVENT_SUITE_BEGIN, (suite: Mocha.Suite) =>
writeEvent([MochaEvent.SuiteStart, { path: suite.titlePath(), file: suite.file }])
);
runner.on(constants.EVENT_TEST_BEGIN, (test: Mocha.Test) =>
writeEvent([MochaEvent.TestStart, clean(test)])
);
runner.on(constants.EVENT_TEST_BEGIN, (test: Mocha.Test) => writeEvent([MochaEvent.TestStart, clean(test)]));
runner.on(constants.EVENT_TEST_PASS, test => writeEvent([MochaEvent.Pass, clean(test)]));
runner.on(constants.EVENT_TEST_FAIL, (test, err) => {
writeEvent([
Expand Down
10 changes: 6 additions & 4 deletions src/runtime/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export class SettingsBasedTestRuntime implements ITestRuntime, Disposable {
const pathToYarnEntry = path.resolve(path.dirname(pathToYarn), 'node_modules/corepack/dist/yarn.js');
nodeLaunchArgs = [
// equal to "yarn node"
'node', pathToYarnEntry, 'node'
'node',
pathToYarnEntry,
'node'
];
}
}
Expand All @@ -81,9 +83,9 @@ export class SettingsBasedTestRuntime implements ITestRuntime, Disposable {
'node'
];
break;
case 'custom':
nodeLaunchArgs = this.settings.customRuntime.value;
break;
case 'custom':
nodeLaunchArgs = this.settings.customRuntime.value;
break;
}

this._runtime = new NodeLikeTestRuntime(this.logChannel, this.configFileUri, this.settings, nodeLaunchArgs);
Expand Down
18 changes: 5 additions & 13 deletions src/test/integration/yarn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@

import { expect } from 'chai';
import * as vscode from 'vscode';
import {
captureTestRun,
expectTestTree,
getController,
integrationTestPrepare
} from '../util';
import { captureTestRun, expectTestTree, getController, integrationTestPrepare } from '../util';

describe('yarn', () => {
integrationTestPrepare('yarn');

it('discovers tests', async () => {
const c = await getController();

expectTestTree(c, [
['hello.test.js', [['math', [['addition'], ['failing'], ['subtraction']]]]]
]);
expectTestTree(c, [['hello.test.js', [['math', [['addition'], ['failing'], ['subtraction']]]]]]);
});

it('runs tests', async () => {
Expand All @@ -44,12 +37,11 @@ describe('yarn', () => {
run.expectStates({
'hello.test.js/math/addition': ['enqueued', 'started', 'passed'],
'hello.test.js/math/subtraction': ['enqueued', 'started', 'passed'],
'hello.test.js/math/failing': ['enqueued', 'started', 'failed'],
'hello.test.js/math/failing': ['enqueued', 'started', 'failed']
});
});


it('debugs tests', async () => {
it('debugs tests', async () => {
const c = await getController();
const profiles = c.profiles;
expect(profiles).to.have.lengthOf(2);
Expand All @@ -66,7 +58,7 @@ describe('yarn', () => {
run.expectStates({
'hello.test.js/math/addition': ['enqueued', 'started', 'passed'],
'hello.test.js/math/subtraction': ['enqueued', 'started', 'passed'],
'hello.test.js/math/failing': ['enqueued', 'started', 'failed'],
'hello.test.js/math/failing': ['enqueued', 'started', 'failed']
});
});
});
14 changes: 8 additions & 6 deletions src/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ export function integrationTestPrepare(name: string) {
async function restoreWorkspace(workspaceFolder: string, workspaceBackup: string) {
const restoredFiles = new Set<string>();
// restore changed files
for(const dirOrFile of await fs.promises.readdir(workspaceBackup, {withFileTypes: true})) {
for (const dirOrFile of await fs.promises.readdir(workspaceBackup, { withFileTypes: true })) {
restoredFiles.add(dirOrFile.name);
if(dirOrFile.isDirectory() && dirOrFile.name === 'node_modules') {
if (dirOrFile.isDirectory() && dirOrFile.name === 'node_modules') {
continue;
}
await fs.promises.cp(path.join(workspaceBackup, dirOrFile.name), path.join(workspaceFolder, dirOrFile.name), { recursive: true });
await fs.promises.cp(path.join(workspaceBackup, dirOrFile.name), path.join(workspaceFolder, dirOrFile.name), {
recursive: true
});
}

// delete new files
for(const dirOrFile of await fs.promises.readdir(workspaceFolder, {withFileTypes: true})) {
if(!restoredFiles.has(dirOrFile.name)) {
for (const dirOrFile of await fs.promises.readdir(workspaceFolder, { withFileTypes: true })) {
if (!restoredFiles.has(dirOrFile.name)) {
await rmrf(path.join(workspaceFolder, dirOrFile.name));
}
}
Expand Down Expand Up @@ -196,7 +198,7 @@ function buildTreeExpectation(entry: TestTreeExpectation, c: vscode.TestItemColl

export function onceChanged(controller: Controller, timeout = 10000) {
return new Promise<void>((resolve, reject) => {
setTimeout(timeout).then(() => reject("Timed out"));
setTimeout(timeout).then(() => reject('Timed out'));
const l = controller.onDidChange(() => {
l.dispose();
resolve();
Expand Down
6 changes: 3 additions & 3 deletions src/workspaceWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export class WorkspaceFolderWatcher {

watcher.onDidCreate(uri => {
const isMatch = configFilePatterns.some(pattern => minimatch(uri.fsPath.replace(/\\/g, '/'), pattern));
if(isMatch) {
const isIgnore = minimatch(uri.fsPath.replace(/\\/g, '/'), ignoreConfigFilePattern);
if(!isIgnore) {
if (isMatch) {
const isIgnore = minimatch(uri.fsPath.replace(/\\/g, '/'), ignoreConfigFilePattern);
if (!isIgnore) {
this.addConfigFile(uri);
return;
}
Expand Down