Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: tests refactor #1955

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/mqttjs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ jobs:
DEBUG: "${{ runner.debug == '1' && 'mqttjs:*' || '' }}"

# upload coverage to Codecov
# https://app.codecov.io/gh/mqttjs/MQTT.js
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
directory: ./coverage/
fail_ci_if_error: false
fail_ci_if_error: true
flags: unittests
name: codecov-mqttjs
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
files: ./junit.xml
fail_ci_if_error: false
flags: unittests-results
name: codecov-mqttjs-test-results
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test/typescript/*.map
**/typings/**
.vscode/
.npmrc
junit.xml

/build/

4 changes: 2 additions & 2 deletions electron-test/test/service/server_launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class ServerLauncher implements Services.ServiceInstance {
}

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

this.#aedesBroker = await start({
protos: ['tcp', 'tls'],
Expand Down
2 changes: 1 addition & 1 deletion nyc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
],
reporter: [
'text',
'lcov',
'lcov'
],
branches: 80,
functions: 89,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"build:browser": "node esbuild.js",
"build": "npm run build:ts && npm run build:browser",
"prepare": "npm run build",
"unit-test:node": "node_modules/.bin/nyc node -r esbuild-register test/runTests.ts",
"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 ",
"unit-test:browser": "wtr",
"test:node": "npm run unit-test:node",
"test:node": "node_modules/.bin/nyc npm run unit-test:node",
"test:browser": "npm run build && npm run unit-test:browser",
"test": "npm run test:node",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions test/abstract_client.ts → test/node/abstract_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { assert } from 'chai'
import sinon from 'sinon'
import fs from 'fs'
import levelStore from 'mqtt-level-store'
import Store from '../src/lib/store'
import Store from '../../src/lib/store'
import serverBuilderFn from './server_helpers_for_client_tests'
import handlePubrel from '../src/lib/handlers/pubrel'
import handlePubrel from '../../src/lib/handlers/pubrel'
import TeardownHelper from './helpers/TeardownHelper'
import handle from '../src/lib/handlers/index'
import handlePublish from '../src/lib/handlers/publish'
import handle from '../../src/lib/handlers/index'
import handlePublish from '../../src/lib/handlers/publish'
import mqtt, {
IClientOptions,
IClientPublishOptions,
IClientSubscribeOptions,
ISubscriptionMap,
ISubscriptionRequest,
} from '../src'
} from '../../src'
import { IPublishPacket, IPubrelPacket, ISubackPacket, QoS } from 'mqtt-packet'
import { DoneCallback, ErrorWithReasonCode } from 'src/lib/shared'
import { fail } from 'assert'
Expand Down
2 changes: 1 addition & 1 deletion test/abstract_store.ts → test/node/abstract_store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IPublishPacket, IPubrelPacket } from 'mqtt-packet'
import { IStore } from '../src'
import { IStore } from '../../src'
import 'should'
import { it, beforeEach, afterEach } from 'node:test'

Expand Down
4 changes: 2 additions & 2 deletions test/client.ts → test/node/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useFakeTimers } from 'sinon'
import mqtt from '../src'
import mqtt from '../../src'
import { assert } from 'chai'
import { fork } from 'child_process'
import path from 'path'
Expand All @@ -18,7 +18,7 @@ import { IClientOptions } from 'src/lib/client'
import { describe, it, after } from 'node:test'

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

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

Expand Down
2 changes: 1 addition & 1 deletion test/client_mqtt5.ts → test/node/client_mqtt5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import abstractClientTests from './abstract_client'
import { MqttServer } from './server'
import serverBuilder from './server_helpers_for_client_tests'
import getPorts from './helpers/port_list'
import mqtt, { ErrorWithReasonCode } from '../src'
import mqtt, { ErrorWithReasonCode } from '../../src'
import { after, describe, it } from 'node:test'

const ports = getPorts(1)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/keepaliveManager.ts → test/node/keepaliveManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, it } from 'node:test'
import KeepaliveManager from '../src/lib/KeepaliveManager'
import KeepaliveManager from '../../src/lib/KeepaliveManager'
import { assert } from 'chai'
import { useFakeTimers, spy, stub } from 'sinon'
import { MqttClient } from 'src'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { DefaultMessageIdProvider, UniqueMessageIdProvider } from '../src'
import { DefaultMessageIdProvider, UniqueMessageIdProvider } from '../../src'
import { describe, it } from 'node:test'

describe('message id provider', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/mqtt.ts → test/node/mqtt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import path from 'path'
import mqtt, { IClientOptions } from '../src'
import mqtt, { IClientOptions } from '../../src'
import { describe, it } from 'node:test'
import 'should'

Expand Down
2 changes: 1 addition & 1 deletion test/mqtt_store.ts → test/node/mqtt_store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store } from '../src'
import { Store } from '../../src'
import { describe, it } from 'node:test'
import 'should'

Expand Down
2 changes: 1 addition & 1 deletion test/secure_client.ts → test/node/secure_client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import fs from 'fs'
import mqtt from '../src'
import mqtt from '../../src'
import abstractClientTests from './abstract_client'
import { MqttSecureServer, MqttServerListener } from './server'
import { assert } from 'chai'
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/store.ts → test/node/store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Store from '../src/lib/store'
import Store from '../../src/lib/store'
import abstractTest from './abstract_store'
import { describe } from 'node:test'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import abstractClientTests from './abstract_client'
import serverBuilder from './server_helpers_for_client_tests'
import { UniqueMessageIdProvider, IClientOptions } from '../src'
import { UniqueMessageIdProvider, IClientOptions } from '../../src'
import getPorts from './helpers/port_list'
import { describe, after } from 'node:test'

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/websocket_client.ts → test/node/websocket_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import assert from 'assert'
import abstractClientTests from './abstract_client'
import getPorts from './helpers/port_list'
import { MqttServerNoWait } from './server'
import mqtt, { IClientOptions } from '../src'
import mqtt, { IClientOptions } from '../../src'
import { after, describe, it } from 'node:test'

const ports = getPorts(4)
Expand Down
57 changes: 0 additions & 57 deletions test/runTests.ts

This file was deleted.

4 changes: 2 additions & 2 deletions web-test-runner.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ await start({
protos: ['tcp', 'tls', 'ws', 'wss'],
wsPort,
wssPort,
key: './test/certs/server-key.pem',
cert: './test/certs/server-cert.pem',
key: './test/browser/certs/server-key.pem',
cert: './test/browser/certs/server-cert.pem',
verbose: true,
stats: false
})
Expand Down