Skip to content

Commit b5b0967

Browse files
authored
ci: tests refactor (#1955)
1 parent 1eed1b6 commit b5b0967

38 files changed

+38
-82
lines changed

.github/workflows/mqttjs-test.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ jobs:
4545
DEBUG: "${{ runner.debug == '1' && 'mqttjs:*' || '' }}"
4646

4747
# upload coverage to Codecov
48+
# https://app.codecov.io/gh/mqttjs/MQTT.js
4849
- name: Upload coverage to Codecov
4950
uses: codecov/codecov-action@v5
5051
with:
5152
directory: ./coverage/
52-
fail_ci_if_error: false
53+
fail_ci_if_error: true
5354
flags: unittests
5455
name: codecov-mqttjs
5556
token: ${{ secrets.CODECOV_TOKEN }}
5657
verbose: true
58+
59+
- name: Upload test results to Codecov
60+
if: ${{ !cancelled() }}
61+
uses: codecov/test-results-action@v1
62+
with:
63+
files: ./junit.xml
64+
fail_ci_if_error: false
65+
flags: unittests-results
66+
name: codecov-mqttjs-test-results
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
verbose: true
5769

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ test/typescript/*.map
1919
**/typings/**
2020
.vscode/
2121
.npmrc
22+
junit.xml
2223

2324
/build/
2425

electron-test/test/service/server_launcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default class ServerLauncher implements Services.ServiceInstance {
1212
}
1313

1414
async onPrepare(): Promise<void> {
15-
const keyPath = pathResolve(__dirname, '../../../test/certs/server-key.pem')
16-
const certPath = pathResolve(__dirname, '../../../test/certs/server-cert.pem')
15+
const keyPath = pathResolve(__dirname, '../../../test/browser/certs/server-key.pem')
16+
const certPath = pathResolve(__dirname, '../../../test/browser/certs/server-cert.pem')
1717

1818
this.#aedesBroker = await start({
1919
protos: ['tcp', 'tls'],

nyc.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
],
1212
reporter: [
1313
'text',
14-
'lcov',
14+
'lcov'
1515
],
1616
branches: 80,
1717
functions: 89,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
"build:browser": "node esbuild.js",
6464
"build": "npm run build:ts && npm run build:browser",
6565
"prepare": "npm run build",
66-
"unit-test:node": "node_modules/.bin/nyc node -r esbuild-register test/runTests.ts",
66+
"unit-test:node": "node -r esbuild-register --test-concurrency 4 --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=spec --test-reporter-destination=stdout --test test/node/*.ts ",
6767
"unit-test:browser": "wtr",
68-
"test:node": "npm run unit-test:node",
68+
"test:node": "node_modules/.bin/nyc npm run unit-test:node",
6969
"test:browser": "npm run build && npm run unit-test:browser",
7070
"test": "npm run test:node",
7171
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
File renamed without changes.
File renamed without changes.

test/abstract_client.ts renamed to test/node/abstract_client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { assert } from 'chai'
55
import sinon from 'sinon'
66
import fs from 'fs'
77
import levelStore from 'mqtt-level-store'
8-
import Store from '../src/lib/store'
8+
import Store from '../../src/lib/store'
99
import serverBuilderFn from './server_helpers_for_client_tests'
10-
import handlePubrel from '../src/lib/handlers/pubrel'
10+
import handlePubrel from '../../src/lib/handlers/pubrel'
1111
import TeardownHelper from './helpers/TeardownHelper'
12-
import handle from '../src/lib/handlers/index'
13-
import handlePublish from '../src/lib/handlers/publish'
12+
import handle from '../../src/lib/handlers/index'
13+
import handlePublish from '../../src/lib/handlers/publish'
1414
import mqtt, {
1515
IClientOptions,
1616
IClientPublishOptions,
1717
IClientSubscribeOptions,
1818
ISubscriptionMap,
1919
ISubscriptionRequest,
20-
} from '../src'
20+
} from '../../src'
2121
import { IPublishPacket, IPubrelPacket, ISubackPacket, QoS } from 'mqtt-packet'
2222
import { DoneCallback, ErrorWithReasonCode } from 'src/lib/shared'
2323
import { fail } from 'assert'

test/abstract_store.ts renamed to test/node/abstract_store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IPublishPacket, IPubrelPacket } from 'mqtt-packet'
2-
import { IStore } from '../src'
2+
import { IStore } from '../../src'
33
import 'should'
44
import { it, beforeEach, afterEach } from 'node:test'
55

test/client.ts renamed to test/node/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useFakeTimers } from 'sinon'
2-
import mqtt from '../src'
2+
import mqtt from '../../src'
33
import { assert } from 'chai'
44
import { fork } from 'child_process'
55
import path from 'path'
@@ -18,7 +18,7 @@ import { IClientOptions } from 'src/lib/client'
1818
import { describe, it, after } from 'node:test'
1919

2020
// eslint-disable-next-line @typescript-eslint/no-var-requires
21-
const pkgJson = require('../package.json')
21+
const pkgJson = require('../../package.json')
2222

2323
const debug = _debug('mqttjs:client-test')
2424

0 commit comments

Comments
 (0)