Skip to content

Commit

Permalink
feat: update test scripts to include unit tests and clean up test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam committed Nov 1, 2024
1 parent ee27aa2 commit 4a6f0f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@
"esbuild:analyze": "pnpm esbuild:base --minify --metafile --analyze && esbuild-visualizer --metadata ./meta.json --open",
"compile:test": "pnpm clean && tsc -b ./test/tsconfig.json",
"lint": "eslint src/** --fix",
"test": "pnpm compile:test && node ./out/test/runTests.js",
"unit-test": "jest --config ./jest.config.js",
"test": "pnpm compile:test && node ./out/test/runTests.js && pnpm unit-test",
"package": "vsce package --no-dependencies",
"release": "npx @yutengjing/release",
"publish:vs-marketplace": "vsce publish --no-dependencies",
Expand Down
20 changes: 2 additions & 18 deletions src/utils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { after, before } from 'node:test';
import { before } from 'node:test';
import { strictEqual, throws } from 'assert';

import promiseSpawn from '@npmcli/promise-spawn';
Expand All @@ -14,22 +14,6 @@ import {
} from './utils';

describe('Utils Tests', () => {
before(() => {
(promiseSpawn as unknown as jest.Mock).mockReset();
// swap the showErrorMessage function with a console.error
vscode.window.showErrorMessage = <T>(
message: string,
...items: T[]
): Thenable<T | undefined> => {
console.error(message);
return Promise.resolve(undefined);
};
});

after(() => {
vscode.window.showInformationMessage('Test end!');
});

describe('checkNull', () => {
it('should return the value if not null', () => {
const result = checkNull('test', 'Error message');
Expand Down Expand Up @@ -89,7 +73,7 @@ describe('Utils Tests', () => {

it('should return stdout on success', async () => {
const result = await runCommand('git', ['status'], '.');
// result.startsWith('On branch');
result.startsWith('On branch');
});
});
});

0 comments on commit 4a6f0f8

Please sign in to comment.