Meaningless Notebook

我輩は雑記帖である。名はまだない。

開発した VSCode 拡張機能のテストコ-ドを NYC でカバレッジ測定すると 0% になる18

自作した拡張機能に機能追加をしてテストコ-ドのカバレッジを確認したら 0% になって焦った話。

暫定対応

VSCode 拡張機能のテストコ-ド実行で使用する VSCode のバ-ジョンが 1.62.2 だと 0% になるが、ひとつ前の 1.62.1 だと正常に測定出来た。

しょうがないので VSCode 拡張機能のテストコード実行で使用する VSCode のバ-ジョンを最新版ではなく 1.62.1 を使用するようにした。

runTest.ts

import * as path from 'path';

import {
	downloadAndUnzipVSCode,
	runTests
} from '@vscode/test-electron';

async function main() {
	try {
		// The folder containing the Extension Manifest package.json
		// Passed to `--extensionDevelopmentPath`
		const extensionDevelopmentPath = path.resolve(__dirname, '../../');

		// The path to test runner
		// Passed to --extensionTestsPath
		const extensionTestsPath = path.resolve(__dirname, './suite/index');

		// Download VS Code, unzip it and run the integration test
		const vscodeExecutablePath = await downloadAndUnzipVSCode('1.62.1');

		await runTests({
			vscodeExecutablePath:     vscodeExecutablePath,
			extensionDevelopmentPath: extensionDevelopmentPath,
			extensionTestsPath:       extensionTestsPath,
			launchArgs:               ["--disable-extensions"],
		});
	} catch (err) {
		console.error('Failed to run tests');
		process.exit(1);
	}
}

main();

参考元

あといつの間にかテストに使用するライブラリが ‘vscode-test’ じゃなくて ‘@vscode/test-electron’ になってたから対応した。

Amazon

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>