Skip to content

Commit

Permalink
feat(testing): Use the Jest testing framework and switch to GitHub Ac…
Browse files Browse the repository at this point in the history
…tions (#254)

* chore: use the jest testing framework

* chore: switch to github actions

The NPM_TOKEN secret should be set in an environment called "publish"
  • Loading branch information
richard-viney committed Apr 22, 2022
1 parent f3e3ef3 commit a91ff2b
Show file tree
Hide file tree
Showing 28 changed files with 16,675 additions and 8,073 deletions.
66 changes: 0 additions & 66 deletions packages/adapters/.circleci/config.yml

This file was deleted.

3 changes: 2 additions & 1 deletion packages/adapters/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"jest": true
},
"extends": [
"eslint:recommended"
Expand Down
37 changes: 37 additions & 0 deletions packages/adapters/.github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish package to NPM

on:
push:
branches:
- master

jobs:
publish-package:
runs-on: ubuntu-20.04
environment: publish

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install packages
uses: bahmutov/npm-install@v1

- name: Run tests
run: npm run test

- name: Run build
run: npm run build

- name: Semantic release
uses: cycjimmy/semantic-release-action@v3
with:
semantic_version: 19.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 24 additions & 0 deletions packages/adapters/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run tests

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install packages
uses: bahmutov/npm-install@v1

- name: Run tests
run: npm run test
7 changes: 7 additions & 0 deletions packages/adapters/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner",
"smikitky.vscode-dicom"
]
}
18 changes: 14 additions & 4 deletions packages/adapters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<hr />

[![CircleCI](https://circleci.com/gh/dcmjs-org/dcmjs.svg?style=svg)](https://circleci.com/gh/dcmjs-org/dcmjs)
[![CI](https://github.com/dcmjs-org/dcmjs/actions/workflows/publish-package.yml/badge.svg)](https://github.com/dcmjs-org/dcmjs/actions?query=workflow:publish-package)

**Note: this code is a work-in-progress and should not be used for production or clinical purposes**

Expand Down Expand Up @@ -36,9 +36,9 @@ _Parts of DICOM that dcmjs *will* focus on:_

_Parts of DICOM that dcmjs *will not* focus on:_

- DIMSE (legacy networking like C-STORE, C-FIND, C-MOVE, etc). See the [dcmjs-dimse project](https://github.com/PantelisGeorgiadis/dcmjs-dimse) for that.
- Physical Media (optical disks). See [this FAQ](https://www.dclunie.com/medical-image-faq/html/index.html) if you need to work with those.
- Image processing. See [dcmjs-imaging](https://github.com/PantelisGeorgiadis/dcmjs-imaging) for this.
- DIMSE (legacy networking like C-STORE, C-FIND, C-MOVE, etc). See the [dcmjs-dimse project](https://github.com/PantelisGeorgiadis/dcmjs-dimse) for that.
- Physical Media (optical disks). See [this FAQ](https://www.dclunie.com/medical-image-faq/html/index.html) if you need to work with those.
- Image processing. See [dcmjs-imaging](https://github.com/PantelisGeorgiadis/dcmjs-imaging) for this.

# Usage

Expand Down Expand Up @@ -103,6 +103,16 @@ Use this repository's issues page to report any bugs. Please follow [SSCCE](http

Use github pull requests to make contributions.

## Unit Tests

Tests are written using the [Jest](https://jestjs.io) testing framework and live in the `test/` folder. Test file names must end with `.test.js`.

Pull requests should either update existing tests or add new tests in order to ensure good test coverage of the changes being made.

To run all tests use `npm run test`. To only run specific tests use Jest's [`.only`](https://www.testim.io/blog/unit-testing-best-practices/) feature. If you're using VS Code, an extension such as [`firsttris.vscode-jest-runner`](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) can be used to step through specific tests in the debugger.

Read all about unit testing best practices [here](https://www.testim.io/blog/unit-testing-best-practices/).

# Status

Currently dcmjs is an early-stage development experiment, but already has valuable functionality.
Expand Down
Loading

0 comments on commit a91ff2b

Please sign in to comment.