Skip to content

Commit

Permalink
chore(tests): update test environments
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Jul 26, 2023
1 parent 7f38d24 commit 2d98894
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 554 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ const config = {
terms: ['@fixme', '@todo']
}
],
'unicorn/explicit-length-check': 2,
'unicorn/explicit-length-check': 0,
'unicorn/filename-case': [
2,
{
Expand Down Expand Up @@ -835,6 +835,7 @@ const config = {
},
plugins: ['chai-expect', 'jest-formatting'],
rules: {
'@typescript-eslint/class-literal-property-style': 0,
'@typescript-eslint/consistent-indexed-object-style': 0,
'@typescript-eslint/no-base-to-string': 0,
'@typescript-eslint/no-empty-function': 0,
Expand All @@ -858,7 +859,6 @@ const config = {
'promise/valid-params': 0,
'unicorn/consistent-destructuring': 0,
'unicorn/error-message': 0,
'unicorn/explicit-length-check': 0,
'unicorn/no-array-for-each': 0,
'unicorn/no-hex-escape': 0,
'unicorn/no-useless-undefined': 0,
Expand Down
4 changes: 2 additions & 2 deletions .github/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ branches:
- context: lint
- context: spelling
- context: typescript (5.0.4)
- context: typescript (~4.8.0)
- context: typescript (~4.9.0)
- context: typescript (5.1.6)
- context: typescript (latest)
strict: true
restrictions: null
# https://docs.github.com/rest/deployments/environments#create-or-update-an-environment
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ jobs:
matrix:
typescript-version:
- ${{ needs.preflight.outputs.version-typescript }}
- ~4.9.0
- ~4.8.0
- latest
- 5.0.4
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
Expand Down Expand Up @@ -268,14 +268,10 @@ jobs:
if: steps.test-files-check.outputs.files_exists == 'true'
name: Install typescript@${{ matrix.typescript-version }}
run: yarn add -D typescript@${{ matrix.typescript-version }}
- id: set-typescript-version
name: Set env.TYPESCRIPT_VERSION
run: |
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
- id: print-typescript-version
if: steps.test-files-check.outputs.files_exists == 'true'
name: Print TypeScript version
run: echo $TYPESCRIPT_VERSION
run: jq .devDependencies.typescript package.json -r
- id: typecheck
if: steps.test-files-check.outputs.files_exists == 'true'
name: Run typecheck
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/typescript-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name: typescript-canary
on:
schedule:
# every day, 3 hours after typescript@next release
# https://github.com/microsoft/TypeScript/blob/v4.9.5/.github/workflows/nightly.yaml
# https://github.com/microsoft/TypeScript/blob/v5.0.4/.github/workflows/nightly.yaml
- cron: 0 10 * * *
workflow_dispatch:
permissions:
Expand Down Expand Up @@ -65,13 +65,9 @@ jobs:
- id: typescript
name: Install typescript@${{ matrix.typescript-version }}
run: yarn add -D typescript@${{ matrix.typescript-version }}
- id: set-typescript-version
name: Set env.TYPESCRIPT_VERSION
run: |
echo "TYPESCRIPT_VERSION=$(jq .devDependencies.typescript package.json -r)" >>$GITHUB_ENV
- id: print-typescript-version
name: Print TypeScript version
run: echo $TYPESCRIPT_VERSION
run: jq .devDependencies.typescript package.json -r
- id: build
name: Build project
run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19
20
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"shellformat.flag": "-ci -fn -i=2 -sr",
"shellformat.useEditorConfig": true,
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.scrollback": 10000,
"todo-tree.filtering.ignoreGitSubmodules": true,
"todo-tree.filtering.includeHiddenFiles": false,
"todo-tree.filtering.useBuiltInExcludes": "file and search excludes",
Expand Down
74 changes: 50 additions & 24 deletions __tests__/reporters/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @module tests/reporters/Notifier
*/

import type { OneOrMany } from '@flex-development/tutils'
import { cast, isArray, type OneOrMany } from '@flex-development/tutils'
import notifier from 'node-notifier'
import type NotificationCenter from 'node-notifier/notifiers/notificationcenter'
import { performance } from 'node:perf_hooks'
Expand All @@ -20,22 +20,28 @@ import type { File, Reporter, Task, Test, Vitest } from 'vitest'
*/
class Notifier implements Reporter {
/**
* Test reporter context.
*
* @public
* @member {Vitest} ctx - Test reporter context
* @member {Vitest} ctx
*/
public ctx: Vitest = {} as Vitest
public ctx!: Vitest

/**
* Test run end time (in milliseconds).
*
* @public
* @member {number} end - Test run end time (in milliseconds)
* @member {number} end
*/
public end: number = 0
public end!: number

/**
* Test run start time (in milliseconds).
*
* @public
* @member {number} start - Test run start time (in milliseconds)
* @member {number} start
*/
public start: number = 0
public start!: number

/**
* Sends a notification.
Expand All @@ -52,19 +58,39 @@ class Notifier implements Reporter {
files: File[] = this.ctx.state.getFiles(),
errors: unknown[] = this.ctx.state.getUnhandledErrors()
): Promise<void> {
/** @const {Test[]} tests - Tests run */
/**
* Tests that have been run.
*
* @const {Test[]} tests
*/
const tests: Test[] = this.tests(files)

/** @const {number} fails - Total number of failed tests */
/**
* Total number of failed tests.
*
* @const {number} fails
*/
const fails: number = tests.filter(t => t.result?.state === 'fail').length

/** @const {number} passes - Total number of passed tests */
/**
* Total number of passed tests.
*
* @const {number} passes
*/
const passes: number = tests.filter(t => t.result?.state === 'pass').length

/** @var {string} message - Notification message */
/**
* Notification message.
*
* @var {string} message
*/
let message: string = ''

/** @var {string} title - Notification title */
/**
* Notification title.
*
* @var {string} title
*/
let title: string = ''

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

title = '\u274C Failed'
} else {
/** @const {number} time - Time to run all tests (in milliseconds) */
/**
* Time to run all tests (in milliseconds).
*
* @const {number} time
*/
const time: number = this.end - this.start

message = dedent`
Expand Down Expand Up @@ -128,29 +158,25 @@ class Notifier implements Reporter {
*/
public onInit(context: Vitest): void {
this.ctx = context
return void (this.start = performance.now())
return void ((this.start = performance.now()) && (this.end = 0))
}

/**
* Returns an array of {@linkcode Test} objects.
* Returns an array of {@link Test} objects.
*
* @protected
*
* @param {OneOrMany<Task>} [tasks=[]] - Tasks to collect tests from
* @return {Test[]} `Test` object array
*/
protected tests(tasks: OneOrMany<Task> = []): Test[] {
const { mode } = this.ctx

return (Array.isArray(tasks) ? tasks : [tasks]).flatMap(task => {
const { type } = task

return mode === 'typecheck' && type === 'suite' && task.tasks.length === 0
? ([task] as unknown as [Test])
: type === 'test'
return (isArray<Task>(tasks) ? tasks : [tasks]).flatMap(task => {
return task.type === 'custom'
? [cast(task)]
: task.type === 'test'
? [task]
: 'tasks' in task
? task.tasks.flatMap(t => (t.type === 'test' ? [t] : this.tests(t)))
? task.tasks.flatMap(task => this.tests(task))
: []
})
}
Expand Down
11 changes: 0 additions & 11 deletions __tests__/ts/v4/tsconfig.build.json

This file was deleted.

53 changes: 0 additions & 53 deletions __tests__/ts/v4/tsconfig.json

This file was deleted.

14 changes: 0 additions & 14 deletions __tests__/ts/v4/tsconfig.typecheck.json

This file was deleted.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"@vates/toggle-scripts": "1.0.0",
"@vitest/coverage-c8": "0.31.1",
"@vitest/ui": "0.31.2",
"add-stream": "1.0.0",
"chai": "4.3.7",
"conventional-changelog": "3.1.25",
Expand Down Expand Up @@ -132,17 +130,16 @@
"pkg-size": "2.4.0",
"prettier": "2.8.8",
"prettier-plugin-sh": "0.12.8",
"radash": "10.8.1",
"sade": "1.8.1",
"semver": "7.5.2",
"tempfile": "5.0.0",
"trash-cli": "5.0.0",
"ts-dedent": "2.2.0",
"typescript": "5.0.4",
"typescript": "5.1.6",
"version-bump-prompt": "6.1.0",
"vite": "4.3.9",
"vite": "4.4.7",
"vite-tsconfig-paths": "4.2.0",
"vitest": "0.31.1",
"vitest": "0.33.0",
"vitest-github-actions-reporter": "0.10.0",
"yaml-eslint-parser": "1.2.2"
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
},
"exclude": ["**/__mocks__", "**/__tests__"],
"extends": "./tsconfig.json",
"files": ["./typings/@types/node/http2.d.ts"],
"include": ["./dist/*", "./src/*"]
}
8 changes: 8 additions & 0 deletions typings/@types/node/http2.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module 'http2' {
import * as stream from 'node:stream'
import * as url from 'node:url'

export interface ClientSessionOptions extends SessionOptions {
createConnection?(authority: url.URL, option: SessionOptions): stream.Duplex
}
}
Loading

0 comments on commit 2d98894

Please sign in to comment.