Skip to content

Commit c539a71

Browse files
committed
Introduce testing with mocha, proxyquire, sinon and nyc
- mocha is the unit testing framework - proxyrequire allows module dependencies to be replaced - sinon creates mocks (fakes used here) - nyc measures coverage Only graphql.js is tested, for a simple start. This adds a lot of dev dependencies, so use `npm ci --production` in the validate workflow.
1 parent b2073bd commit c539a71

File tree

7 files changed

+1567
-22
lines changed

7 files changed

+1567
-22
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on: [push, pull_request]
22
name: lint
33
jobs:
4-
validate:
4+
lint:
55
runs-on: ubuntu-18.04
66
steps:
77
- name: Checkout

.github/workflows/test.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on: [push, pull_request]
2+
name: test
3+
jobs:
4+
test:
5+
runs-on: ubuntu-18.04
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v1
9+
- name: Setup Node.js
10+
uses: actions/setup-node@v1
11+
with:
12+
node-version: 12.x
13+
- name: Setup dependencies
14+
run: |
15+
echo '{}' > config.json
16+
npm ci
17+
- name: Run tests
18+
run: npm test

.github/workflows/validate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup dependencies
1919
run: |
2020
echo '{"w3capikey":"${{ secrets.W3C_API_KEY }}","ghToken":"${{ secrets.W3C_GITHUB_TOKEN }}"}' > config.json
21-
npm ci
21+
npm ci --production
2222
- name: Run validate.js
2323
run: node validate.js > report.json
2424
- name: Push report.json updates

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
config.json
22
node_modules/
3+
.nyc_output/

0 commit comments

Comments
 (0)