Skip to content

Commit c1d952f

Browse files
committed
feat: fix tests and move to all native test
1 parent 2a1bc28 commit c1d952f

10 files changed

+87
-29
lines changed

.github/workflows/node.js.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
name: Node ${{ matrix.node-version }}
2020
steps:
2121
- uses: actions/checkout@v4
22-
- name: Use Node.js ${{ matrix.node-version }}
22+
- name: Setup Node
2323
uses: actions/setup-node@v4
2424
with:
2525
node-version: ${{ matrix.node-version }}
2626
- run: npm install
27-
- run: npm run test
27+
- run: npm test

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
node_modules
22
dist
33
*.vsix
4-
.tsimp
54

65
coverage

.travis.yml

-3
This file was deleted.

.xo-config.json

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"rules": {
1717
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]
1818
}
19+
},
20+
{
21+
"files": "test/**/*.ts",
22+
"rules": {
23+
"@typescript-eslint/no-floating-promises": "off"
24+
}
1925
}
2026
]
2127
}

package-lock.json

+52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"lint": "xo && npm run lint:md",
4444
"lint:md": "prettier --parser markdown '**/*.md' --check",
4545
"prepare": "husky install",
46-
"test:": "rimraf .tsimp && NODE_NO_WARNINGS=1 node --import tsimp/import --test test/native/**/*.ts",
47-
"test:coverage": "rimraf .tsimp && NODE_NO_WARNINGS=1 c8 node --import tsimp/import --test test/native/**/*.ts",
46+
"test": "NODE_NO_WARNINGS=1 node --require tsx/cjs --test test/index.ts",
47+
"test:coverage": "NODE_NO_WARNINGS=1 c8 node --require tsx/cjs --test test/index.ts",
4848
"vscode:prepublish": "npm run check && npm run build"
4949
},
5050
"contributes": {
@@ -212,7 +212,7 @@
212212
"prettier": "^3.1.1",
213213
"prettier-plugin-packagejson": "^2.4.9",
214214
"rimraf": "^5.0.5",
215-
"tsimp": "^2.0.10",
215+
"tsx": "^4.7.0",
216216
"typescript": "^5.3.3",
217217
"webfont": "^6.0.2",
218218
"xo": "^0.56.0"

test/index.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
2-
import {test, describe} from 'node:test';
3-
import assert from 'node:assert';
4-
import Server from '../server/server.js';
1+
/* eslint-disable import/no-unassigned-import */
2+
// since globs are not fully supported in node v18 and v20 we import the files manually here
53

6-
describe('Server', () => {
7-
test('Server is a function', (t) => {
8-
assert.strictEqual(typeof Server, 'function');
9-
});
10-
11-
test('Server can instantiate', (t) => {
12-
const server = new Server({isTest: true});
13-
assert.strictEqual(typeof server, 'object');
14-
});
15-
});
4+
// TODO: remove this file once node v21 is LTS
5+
import './server.js';
6+
import './lsp/document-sync.js';
7+
import './lsp/initialization.js';

test/lsp/document-sync.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
21
import {test, describe, mock, type Mock} from 'node:test';
32
import assert from 'node:assert';
43
import {TextDocument} from 'vscode-languageserver-textdocument';

test/lsp/initialization.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises */
21
import {describe, test} from 'node:test';
32
import assert from 'node:assert';
43
import Server from '../../server/server.js';
54

6-
const server = new Server({isTest: true});
5+
describe('Server.handleInitialize', async () => {
6+
const server = new Server({isTest: true});
77

8-
describe('Server.handleInitialize', () => {
9-
test('Server.handleInitialize is a function', (t) => {
8+
await test('Server.handleInitialize is a function', (t) => {
109
assert.equal(typeof server.handleInitialize, 'function');
1110
});
1211

13-
test('InitializeResult matches snapshot', async (t) => {
12+
await test('InitializeResult matches snapshot', async (t) => {
1413
const result = await server.handleInitialize();
1514
assert.deepEqual(result, {
1615
capabilities: {

test/server.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {test, describe} from 'node:test';
2+
import assert from 'node:assert';
3+
import Server from '../server/server.js';
4+
5+
describe('Server', () => {
6+
test('Server is a function', (t) => {
7+
assert.strictEqual(typeof Server, 'function');
8+
});
9+
10+
test('Server can instantiate', (t) => {
11+
const server = new Server({isTest: true});
12+
assert.strictEqual(typeof server, 'object');
13+
});
14+
});

0 commit comments

Comments
 (0)