Skip to content

Commit 2d98894

Browse files
committed
chore(tests): update test environments
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 7f38d24 commit 2d98894

15 files changed

+469
-554
lines changed

.eslintrc.base.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ const config = {
661661
terms: ['@fixme', '@todo']
662662
}
663663
],
664-
'unicorn/explicit-length-check': 2,
664+
'unicorn/explicit-length-check': 0,
665665
'unicorn/filename-case': [
666666
2,
667667
{
@@ -835,6 +835,7 @@ const config = {
835835
},
836836
plugins: ['chai-expect', 'jest-formatting'],
837837
rules: {
838+
'@typescript-eslint/class-literal-property-style': 0,
838839
'@typescript-eslint/consistent-indexed-object-style': 0,
839840
'@typescript-eslint/no-base-to-string': 0,
840841
'@typescript-eslint/no-empty-function': 0,
@@ -858,7 +859,6 @@ const config = {
858859
'promise/valid-params': 0,
859860
'unicorn/consistent-destructuring': 0,
860861
'unicorn/error-message': 0,
861-
'unicorn/explicit-length-check': 0,
862862
'unicorn/no-array-for-each': 0,
863863
'unicorn/no-hex-escape': 0,
864864
'unicorn/no-useless-undefined': 0,

.github/infrastructure.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ branches:
3131
- context: lint
3232
- context: spelling
3333
- context: typescript (5.0.4)
34-
- context: typescript (~4.8.0)
35-
- context: typescript (~4.9.0)
34+
- context: typescript (5.1.6)
35+
- context: typescript (latest)
3636
strict: true
3737
restrictions: null
3838
# https://docs.github.com/rest/deployments/environments#create-or-update-an-environment

.github/workflows/ci.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ jobs:
235235
matrix:
236236
typescript-version:
237237
- ${{ needs.preflight.outputs.version-typescript }}
238-
- ~4.9.0
239-
- ~4.8.0
238+
- latest
239+
- 5.0.4
240240
steps:
241241
- id: checkout
242242
name: Checkout ${{ env.REF_NAME }}
@@ -268,14 +268,10 @@ jobs:
268268
if: steps.test-files-check.outputs.files_exists == 'true'
269269
name: Install typescript@${{ matrix.typescript-version }}
270270
run: yarn add -D typescript@${{ matrix.typescript-version }}
271-
- id: set-typescript-version
272-
name: Set env.TYPESCRIPT_VERSION
273-
run: |
274-
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
275271
- id: print-typescript-version
276272
if: steps.test-files-check.outputs.files_exists == 'true'
277273
name: Print TypeScript version
278-
run: echo $TYPESCRIPT_VERSION
274+
run: jq .devDependencies.typescript package.json -r
279275
- id: typecheck
280276
if: steps.test-files-check.outputs.files_exists == 'true'
281277
name: Run typecheck

.github/workflows/typescript-canary.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ name: typescript-canary
2121
on:
2222
schedule:
2323
# every day, 3 hours after typescript@next release
24-
# https://github.com/microsoft/TypeScript/blob/v4.9.5/.github/workflows/nightly.yaml
24+
# https://github.com/microsoft/TypeScript/blob/v5.0.4/.github/workflows/nightly.yaml
2525
- cron: 0 10 * * *
2626
workflow_dispatch:
2727
permissions:
@@ -65,13 +65,9 @@ jobs:
6565
- id: typescript
6666
name: Install typescript@${{ matrix.typescript-version }}
6767
run: yarn add -D typescript@${{ matrix.typescript-version }}
68-
- id: set-typescript-version
69-
name: Set env.TYPESCRIPT_VERSION
70-
run: |
71-
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
7268
- id: print-typescript-version
7369
name: Print TypeScript version
74-
run: echo $TYPESCRIPT_VERSION
70+
run: jq .devDependencies.typescript package.json -r
7571
- id: build
7672
name: Build project
7773
run: yarn build

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19
1+
20

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
"shellformat.flag": "-ci -fn -i=2 -sr",
257257
"shellformat.useEditorConfig": true,
258258
"terminal.integrated.copyOnSelection": true,
259+
"terminal.integrated.scrollback": 10000,
259260
"todo-tree.filtering.ignoreGitSubmodules": true,
260261
"todo-tree.filtering.includeHiddenFiles": false,
261262
"todo-tree.filtering.useBuiltInExcludes": "file and search excludes",

__tests__/reporters/notifier.ts

+50-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @module tests/reporters/Notifier
44
*/
55

6-
import type { OneOrMany } from '@flex-development/tutils'
6+
import { cast, isArray, type OneOrMany } from '@flex-development/tutils'
77
import notifier from 'node-notifier'
88
import type NotificationCenter from 'node-notifier/notifiers/notificationcenter'
99
import { performance } from 'node:perf_hooks'
@@ -20,22 +20,28 @@ import type { File, Reporter, Task, Test, Vitest } from 'vitest'
2020
*/
2121
class Notifier implements Reporter {
2222
/**
23+
* Test reporter context.
24+
*
2325
* @public
24-
* @member {Vitest} ctx - Test reporter context
26+
* @member {Vitest} ctx
2527
*/
26-
public ctx: Vitest = {} as Vitest
28+
public ctx!: Vitest
2729

2830
/**
31+
* Test run end time (in milliseconds).
32+
*
2933
* @public
30-
* @member {number} end - Test run end time (in milliseconds)
34+
* @member {number} end
3135
*/
32-
public end: number = 0
36+
public end!: number
3337

3438
/**
39+
* Test run start time (in milliseconds).
40+
*
3541
* @public
36-
* @member {number} start - Test run start time (in milliseconds)
42+
* @member {number} start
3743
*/
38-
public start: number = 0
44+
public start!: number
3945

4046
/**
4147
* Sends a notification.
@@ -52,19 +58,39 @@ class Notifier implements Reporter {
5258
files: File[] = this.ctx.state.getFiles(),
5359
errors: unknown[] = this.ctx.state.getUnhandledErrors()
5460
): Promise<void> {
55-
/** @const {Test[]} tests - Tests run */
61+
/**
62+
* Tests that have been run.
63+
*
64+
* @const {Test[]} tests
65+
*/
5666
const tests: Test[] = this.tests(files)
5767

58-
/** @const {number} fails - Total number of failed tests */
68+
/**
69+
* Total number of failed tests.
70+
*
71+
* @const {number} fails
72+
*/
5973
const fails: number = tests.filter(t => t.result?.state === 'fail').length
6074

61-
/** @const {number} passes - Total number of passed tests */
75+
/**
76+
* Total number of passed tests.
77+
*
78+
* @const {number} passes
79+
*/
6280
const passes: number = tests.filter(t => t.result?.state === 'pass').length
6381

64-
/** @var {string} message - Notification message */
82+
/**
83+
* Notification message.
84+
*
85+
* @var {string} message
86+
*/
6587
let message: string = ''
6688

67-
/** @var {string} title - Notification title */
89+
/**
90+
* Notification title.
91+
*
92+
* @var {string} title
93+
*/
6894
let title: string = ''
6995

7096
// get notification title and message based on number of failed tests
@@ -76,7 +102,11 @@ class Notifier implements Reporter {
76102

77103
title = '\u274C Failed'
78104
} else {
79-
/** @const {number} time - Time to run all tests (in milliseconds) */
105+
/**
106+
* Time to run all tests (in milliseconds).
107+
*
108+
* @const {number} time
109+
*/
80110
const time: number = this.end - this.start
81111

82112
message = dedent`
@@ -128,29 +158,25 @@ class Notifier implements Reporter {
128158
*/
129159
public onInit(context: Vitest): void {
130160
this.ctx = context
131-
return void (this.start = performance.now())
161+
return void ((this.start = performance.now()) && (this.end = 0))
132162
}
133163

134164
/**
135-
* Returns an array of {@linkcode Test} objects.
165+
* Returns an array of {@link Test} objects.
136166
*
137167
* @protected
138168
*
139169
* @param {OneOrMany<Task>} [tasks=[]] - Tasks to collect tests from
140170
* @return {Test[]} `Test` object array
141171
*/
142172
protected tests(tasks: OneOrMany<Task> = []): Test[] {
143-
const { mode } = this.ctx
144-
145-
return (Array.isArray(tasks) ? tasks : [tasks]).flatMap(task => {
146-
const { type } = task
147-
148-
return mode === 'typecheck' && type === 'suite' && task.tasks.length === 0
149-
? ([task] as unknown as [Test])
150-
: type === 'test'
173+
return (isArray<Task>(tasks) ? tasks : [tasks]).flatMap(task => {
174+
return task.type === 'custom'
175+
? [cast(task)]
176+
: task.type === 'test'
151177
? [task]
152178
: 'tasks' in task
153-
? task.tasks.flatMap(t => (t.type === 'test' ? [t] : this.tests(t)))
179+
? task.tasks.flatMap(task => this.tests(task))
154180
: []
155181
})
156182
}

__tests__/ts/v4/tsconfig.build.json

-11
This file was deleted.

__tests__/ts/v4/tsconfig.json

-53
This file was deleted.

__tests__/ts/v4/tsconfig.typecheck.json

-14
This file was deleted.

package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@
9494
"@typescript-eslint/eslint-plugin": "5.59.8",
9595
"@typescript-eslint/parser": "5.59.8",
9696
"@vates/toggle-scripts": "1.0.0",
97-
"@vitest/coverage-c8": "0.31.1",
98-
"@vitest/ui": "0.31.2",
9997
"add-stream": "1.0.0",
10098
"chai": "4.3.7",
10199
"conventional-changelog": "3.1.25",
@@ -132,17 +130,16 @@
132130
"pkg-size": "2.4.0",
133131
"prettier": "2.8.8",
134132
"prettier-plugin-sh": "0.12.8",
135-
"radash": "10.8.1",
136133
"sade": "1.8.1",
137134
"semver": "7.5.2",
138135
"tempfile": "5.0.0",
139136
"trash-cli": "5.0.0",
140137
"ts-dedent": "2.2.0",
141-
"typescript": "5.0.4",
138+
"typescript": "5.1.6",
142139
"version-bump-prompt": "6.1.0",
143-
"vite": "4.3.9",
140+
"vite": "4.4.7",
144141
"vite-tsconfig-paths": "4.2.0",
145-
"vitest": "0.31.1",
142+
"vitest": "0.33.0",
146143
"vitest-github-actions-reporter": "0.10.0",
147144
"yaml-eslint-parser": "1.2.2"
148145
},

tsconfig.build.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
},
88
"exclude": ["**/__mocks__", "**/__tests__"],
99
"extends": "./tsconfig.json",
10+
"files": ["./typings/@types/node/http2.d.ts"],
1011
"include": ["./dist/*", "./src/*"]
1112
}

typings/@types/node/http2.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare module 'http2' {
2+
import * as stream from 'node:stream'
3+
import * as url from 'node:url'
4+
5+
export interface ClientSessionOptions extends SessionOptions {
6+
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex
7+
}
8+
}

0 commit comments

Comments
 (0)