Skip to content

Commit

Permalink
Switch to mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team authored Oct 7, 2023
1 parent 794ad3c commit c9a955c
Show file tree
Hide file tree
Showing 16 changed files with 788 additions and 88 deletions.
4 changes: 4 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extension": [".ts"],
"reporter": ["text", "lcov"]
}
7 changes: 4 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"parserOptions": {
"ecmaVersion": 2019,
"ecmaVersion": 2021,
"project": ["./tsconfig.json"]
},
"extends": [
"@myrotvorets/myrotvorets-ts"
"@myrotvorets/myrotvorets-ts",
"plugin:mocha/recommended"
],
"env": {
"node": true,
"jest": true
"mocha": true
}
}
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,23 @@ jobs:
uses: myrotvorets/composite-actions/build-test-nodejs@master
with:
node-version: ${{ matrix.node.version }}

lint:
name: Check Code Style
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') || github.event_name == 'workflow_dispatch' }}
steps:
- name: Run code style check
uses: myrotvorets/composite-actions/node-run-script@master
with:
script: lint

typecheck:
name: Check Types
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') || github.event_name == 'workflow_dispatch' }}
steps:
- name: Run type check
uses: myrotvorets/composite-actions/node-run-script@master
with:
script: typecheck
1 change: 1 addition & 0 deletions .github/workflows/package-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Package Audit
on:
push:
branches:
- '**'
paths:
- package.json
- package-lock.json
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/sonarscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
permissions:
contents: read

env:
SONARSCANNER: "true"
COLLECT_COVERAGE: "1"

jobs:
build:
name: SonarCloud Scan
Expand All @@ -29,3 +25,5 @@ jobs:
uses: myrotvorets/composite-actions/node-sonarscan@master
with:
sonar-token: ${{ secrets.SONAR_TOKEN }}
test-script: 'test:coverage'

11 changes: 11 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
recursive: true,
extension: ['.test.ts'],
require: 'mocha.setup.js',
reporter: 'mocha-multi',
'reporter-option': [
'spec=-',
process.env.GITHUB_ACTIONS === 'true' ? 'mocha-reporter-gha=-' : null,
process.env.SONARSCANNER === 'true' ? 'mocha-reporter-sonarqube=test-report.xml' : null,
].filter(Boolean),
}
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
tag-version-prefix=
sign-git-tag=true
21 changes: 0 additions & 21 deletions jest.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/writablebufferstream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class WritableBufferStream extends Writable {
public writeP(chunk: unknown, encoding?: BufferEncoding): Promise<void> {
return new Promise((resolve, reject) => {
const callback = (err?: Error | null): void => {
// istanbul ignore if
/* c8 ignore next 2 */
if (err) {
reject(err);
} else {
Expand Down
6 changes: 6 additions & 0 deletions mocha.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require('ts-node/register');

const { use } = require('chai');
const chaiAsPromised = require('chai-as-promised');

use(chaiAsPromised);
Loading

0 comments on commit c9a955c

Please sign in to comment.