From d717785d42b45761e8640f9313b324e600effc19 Mon Sep 17 00:00:00 2001 From: Hao Chen <501018786@qq.com> Date: Thu, 10 Oct 2024 22:22:46 +0800 Subject: [PATCH 1/2] build(tests): type check integration.test.ts --- .../__tests__/integration.test.ts | 21 ++++++++++--------- packages/integration-tests/tsconfig.json | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/integration-tests/__tests__/integration.test.ts b/packages/integration-tests/__tests__/integration.test.ts index 47231301..e682cab8 100644 --- a/packages/integration-tests/__tests__/integration.test.ts +++ b/packages/integration-tests/__tests__/integration.test.ts @@ -1,8 +1,8 @@ /* eslint-env jest */ -import * as cp from 'child_process'; -import * as fs from 'fs'; -import * as path from 'path'; -import * as http from 'http'; +import * as cp from 'node:child_process'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import * as http from 'node:http'; import { NeovimClient, attach, findNvim } from 'neovim'; @@ -37,11 +37,11 @@ describe('Node host', () => { ` ); - const minVersion = '0.9.5' - const nvimInfo = findNvim({ minVersion: minVersion }); + const minVersion = '0.9.5'; + const nvimInfo = findNvim({ minVersion }); const nvimPath = nvimInfo.matches[0]?.path; if (!nvimPath) { - throw new Error(`nvim ${minVersion} not found`) + throw new Error(`nvim ${minVersion} not found`); } cp.spawnSync(nvimPath, args); @@ -115,10 +115,10 @@ describe('Node host', () => { const childHost = cp.spawn( process.execPath, [path.join(__dirname, '..', '..', 'neovim', 'bin', 'cli.js')], - { env: { NVIM_NODE_HOST_DEBUG: 1 }, stdio: 'ignore' } + { env: { NVIM_NODE_HOST_DEBUG: 'TRUE' }, stdio: 'ignore' } ); - setTimeout(function () { + setTimeout(() => { http.get('http://127.0.0.1:9229/json/list', res => { let rawData = ''; res.on('data', chunk => { @@ -133,7 +133,8 @@ describe('Node host', () => { 'ws://127.0.0.1:9229' ); done(); - } catch (e) { + } catch (e: any) { + // eslint-disable-next-line no-console console.error(e.message); throw e; } diff --git a/packages/integration-tests/tsconfig.json b/packages/integration-tests/tsconfig.json index 6521e21b..fd982030 100644 --- a/packages/integration-tests/tsconfig.json +++ b/packages/integration-tests/tsconfig.json @@ -3,6 +3,6 @@ "compilerOptions": { "outDir": "./lib" }, - "include": ["src"], - "exclude": ["node_modules", "__tests__", "**/*.test.ts", "examples", "lib"] + "include": ["src", "__tests__"], + "exclude": ["node_modules", "examples", "lib"] } From 2e42d14742d75c7f5ffd05aac77ccb19d8bc748b Mon Sep 17 00:00:00 2001 From: Hao Chen <501018786@qq.com> Date: Thu, 10 Oct 2024 22:49:20 +0800 Subject: [PATCH 2/2] Avoid jest runs on js files --- packages/integration-tests/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 31179859..c714badb 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -53,5 +53,9 @@ "jest": "^29.7.0", "jest-haste-map": "^29.7.0", "jest-resolve": "^29.6.1" + }, + "jest": { + "testEnvironment": "node", + "testPathIgnorePatterns": [".d.ts", ".js"] } }