Skip to content

Commit

Permalink
chore: ci workaround mocha issue
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Jun 20, 2024
1 parent a1813fc commit e1bc96a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
20 changes: 16 additions & 4 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
import * as path from 'path';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'node:path';
import * as fs from 'node:fs';
import * as os from 'node:os';
import { platform } from 'node:process';
import { defineConfig } from '@vscode/test-cli';
import { globSync } from 'glob';

// Workaround https://github.com/microsoft/vscode/issues/86382, but creating a tmp user data dir
const userDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vscode-humanitec-'));

let files = 'out/test/**/*.test.js';

if (platform === 'win32') {
// Workaround https://github.com/mochajs/mocha/issues/4851
files = globSync('out/test/**/*.test.js', { absolute: true }).map(f =>
f.toLowerCase()
);
}

export default defineConfig([
{
label: 'unitTests',
files: 'out/test/**/*.test.js',
files,
workspaceFolder: './src/test/test-fixtures/workspace',
mocha: {
ui: 'tdd',
timeout: 20000,
asyncOnly: true,
failZero: true,
},
launchArgs: [`--user-data-dir=${userDir}`, '--disable-extensions'],
},
Expand Down
7 changes: 5 additions & 2 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { Environment } from '../../domain/Environment';
import { loggerChannel } from '../../extension';
import { readEnv } from '../utils';

// Those tests aren't working on Windows yet.
const expectWindowsTest = process.platform === 'win32' ? test.skip : test;

suite('Extension Test Suite', () => {
let humanitecOrg: string;
let sandbox: sinon.SinonSandbox;
Expand Down Expand Up @@ -132,7 +135,7 @@ suite('Extension Test Suite', () => {
});

// TODO: We might want to improve this case.
test('fails with a not deployed app / env', async () => {
expectWindowsTest('fails with a not deployed app / env', async () => {
await vscode.commands.executeCommand(
'humanitec.sidebar.organization_structure.set_in_workspace',
new Environment(
Expand All @@ -158,7 +161,7 @@ suite('Extension Test Suite', () => {
);
});

test('works with a deployed app / env', async () => {
expectWindowsTest('works with a deployed app / env', async () => {
await vscode.commands.executeCommand(
'humanitec.sidebar.organization_structure.set_in_workspace',
new Environment('development', 'Development', humanitecOrg, 'deployed')
Expand Down
5 changes: 4 additions & 1 deletion src/test/suite/validate_score_file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { readEnv } from '../utils';
const expect = chai.expect;
chai.use(sinonChai);

suite('When validate score file command triggered', () => {
// Those tests aren't working on Windows yet.
const expectWindowsSuite = process.platform === 'win32' ? suite.skip : suite;

expectWindowsSuite('When validate score file command triggered', () => {
const statusBarItemShow = sinon.spy();
const statusBarItemHide = sinon.spy();
const humanitecOrg = readEnv('TEST_HUMANITEC_ORG');
Expand Down

0 comments on commit e1bc96a

Please sign in to comment.