Skip to content

Commit

Permalink
update contributing doc on unit test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed Oct 6, 2023
1 parent d189aa4 commit f9ea82f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
2 changes: 2 additions & 0 deletions queries/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
coverage/
69 changes: 31 additions & 38 deletions queries/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ When contributing, apply this project's JavaScript standard style, otherwise it

## Requirements

- Node 20.8.0
- Node 18.18.0
- NPM
- ElasticSearch 7.17

Expand All @@ -19,72 +19,65 @@ $ git clone https://github.com/perftool-incubator/CommonDataModel.git
2. Change your current working directory to the CDMQ directory.

```shell
$ cd CommonDataModel/queries/cdmq
$ cd CommonDataModel
```

3. Install this project's Node JS dependencies.

```shell
$ npm install
$ npm install --prefix queries
```

4. Check current code style if changes are required with [prettier](https://prettier.io/docs/en/cli.html) using [npx](https://docs.npmjs.com/cli/v7/commands/npx).

```shell
$ npx prettier *.js --check
$ npx prettier --check "queries/**/*.js"
```

5. Apply code style changes.

```shell
$ npx prettier *.js --write
$ npx prettier --write "queries/**/*.js"
```

## Unit Tests

1. Change your current working directory to the CDMQ directory.

```shell
$ cd CommonDataModel/queries/cdmq
```

2. Verify Node 20.8.0
1. Verify Node 18

```shell
$ node -v
v20.8.0
v18.18.0
```

3. Install this project's Node JS dependencies.
2. Install this project's Node JS dependencies.

```shell
$ npm install
$ npm install --prefix queries
```

3. Execute all JavaScript unit test files with code coverage.

```shell
$ node --experimental-test-coverage queries/cdmq/test/*.test.js

✔ set(ish) difference (subtractTwoArrays) (1.599154ms)
✔ set(ish) intersection (intersectTwoArrays) (0.161839ms)
✔ intersect all arrays (0.154675ms)
ℹ tests 3
ℹ suites 0
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 9.275733
ℹ start of coverage report
ℹ ---------------------------------------------------------------------------------------------
ℹ file | line % | branch % | funcs % | uncovered lines
ℹ ---------------------------------------------------------------------------------------------
ℹ …/cdm.js | 13.30 | 100.00 | 8.82 | 5-7 22-28 31-39 64-76 86-178 188-195 199 204-211 2…
ℹ …test.js | 100.00 | 100.00 | 100.00 |
ℹ ---------------------------------------------------------------------------------------------
ℹ all fil… | 15.05 | 100.00 | 12.68 |
ℹ ---------------------------------------------------------------------------------------------
ℹ end of coverage report
$ npm test --prefix queries

> [email protected] test
> jest

PASS test/cdm.test.js
set(ish)-array behavior
✓ set(ish) difference (subtractTwoArrays) (6 ms)
✓ set(ish) intersection (intersectTwoArrays) (1 ms)
✓ intersect all arrays (1 ms)

----------|---------|----------|---------|---------|-------------------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------------------------------
All files | 10.63 | 100 | 4.61 | 10.63 |
cdm.js | 10.63 | 100 | 4.61 | 10.63 | ...720-1729,1744-2022,2026-2041,2057-2180
----------|---------|----------|---------|---------|-------------------------------------------
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.703 s, estimated 1 s
Ran all test suites.
```
3 changes: 2 additions & 1 deletion queries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Query Utils for Common Data Model",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest",
"prettier": "prettier"
},
"author": "Andrew Theurer",
"license": "ISC",
Expand Down

0 comments on commit f9ea82f

Please sign in to comment.