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

replace mocha and nyc with native node test runner and c8 #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ jobs:

- name: Run tests
shell: bash
run: |
if npm -ps ls nyc | grep -q nyc; then
npm run test-ci
else
npm test
fi
run: npm run test-ci

- name: Lint code
if: steps.list_env.outputs.eslint != ''
run: npm run lint

- name: Collect code coverage
uses: coverallsapp/github-action@master
if: steps.list_env.outputs.nyc != ''
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.test_number }}
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
],
"repository": "jshttp/negotiator",
"devDependencies": {
"c8": "^10.1.2",
"eslint": "7.32.0",
"eslint-plugin-markdown": "2.2.1",
"mocha": "9.1.3",
"nyc": "15.1.0"
"eslint-plugin-markdown": "2.2.1"
},
"files": [
"lib/",
Expand All @@ -35,9 +34,8 @@
},
"scripts": {
"lint": "eslint .",
"test": "mocha --reporter spec --check-leaks --bail test/",
"test:debug": "mocha --reporter spec --check-leaks --inspect --inspect-brk test/",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
"test": "node --test --test-reporter spec",
"test-ci": "c8 --reporter=lcovonly --reporter=text npm test",
"test-cov": "c8 --reporter=html --reporter=text npm test"
}
}
11 changes: 8 additions & 3 deletions test/charset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

var nodeTest = require('node:test')
var describe = nodeTest.describe
var it = nodeTest.it
var before = nodeTest.before
var assert = require('assert')
var Negotiator = require('..')

Expand Down Expand Up @@ -326,10 +329,12 @@ function whenAcceptCharset(acceptCharset, func) {
: 'when Accept-Charset: ' + acceptCharset

describe(description, function () {
var thisArg = {}

before(function () {
this.negotiator = new Negotiator(createRequest({'Accept-Charset': acceptCharset}))
thisArg.negotiator = new Negotiator(createRequest({'Accept-Charset': acceptCharset}))
})

func()
func.bind(thisArg)
})
}
11 changes: 8 additions & 3 deletions test/encoding.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

var nodeTest = require('node:test')
var describe = nodeTest.describe
var it = nodeTest.it
var before = nodeTest.before
var assert = require('assert')
var Negotiator = require('..')

Expand Down Expand Up @@ -467,10 +470,12 @@ function whenAcceptEncoding(acceptEncoding, func) {
: 'when Accept-Encoding: ' + acceptEncoding

describe(description, function () {
var thisArg = {}

before(function () {
this.negotiator = new Negotiator(createRequest({'Accept-Encoding': acceptEncoding}))
thisArg.negotiator = new Negotiator(createRequest({'Accept-Encoding': acceptEncoding}))
})

func()
func.bind(thisArg)
})
}
11 changes: 8 additions & 3 deletions test/language.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

var nodeTest = require('node:test')
var describe = nodeTest.describe
var it = nodeTest.it
var before = nodeTest.before
var assert = require('assert')
var Negotiator = require('..')

Expand Down Expand Up @@ -422,10 +425,12 @@ function whenAcceptLanguage(acceptLanguage, func) {
: 'when Accept-Language: ' + acceptLanguage

describe(description, function () {
var thisArg = {}

before(function () {
this.negotiator = new Negotiator(createRequest({'Accept-Language': acceptLanguage}))
thisArg.negotiator = new Negotiator(createRequest({'Accept-Language': acceptLanguage}))
})

func()
func.bind(thisArg)
})
}
11 changes: 8 additions & 3 deletions test/mediaType.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

var nodeTest = require('node:test')
var describe = nodeTest.describe
var it = nodeTest.it
var before = nodeTest.before
var assert = require('assert')
var Negotiator = require('..')

Expand Down Expand Up @@ -490,10 +493,12 @@ function whenAccept(accept, func) {
: 'when Accept: ' + accept

describe(description, function () {
var thisArg = {}

before(function () {
this.negotiator = Negotiator(createRequest({'Accept': accept}))
thisArg.negotiator = Negotiator(createRequest({ 'Accept': accept }))
})

func()
func.bind(thisArg)
})
}