Skip to content

Commit

Permalink
ci: add test on node 10
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnysunny committed May 3, 2022
1 parent dba8b08 commit 2fa2541
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
include:
- node-version: 10.x
test-on-old-node: 1
- node-version: 12.x
# test-on-brower: 1
- node-version: 14.x
Expand All @@ -35,7 +36,7 @@ jobs:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies On Node 10
if: ${{ matrix.node-version == '10.x' }}
run: yarn install --ignore-optional
run: yarn install --ignore-optional --ignore-scripts
- name: Install Dependencies On Node ${{ matrix.node-version }}
if: ${{ matrix.node-version != '10.x' }}
run: yarn install
Expand All @@ -45,6 +46,8 @@ jobs:
env:
BROWSER: ${{ matrix.test-on-brower }}
HTTP2_TEST: ${{ matrix.test-http2 }}
OLD_NODE_TEST: ${{ matrix.test-on-old-node }}
run: |
npm run test
- name: Coverage On Node ${{ matrix.node-version }}
npm run coverage
6 changes: 6 additions & 0 deletions .lib.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
}
}]
],
"plugins": [
["@babel/transform-runtime"]
],
"parserOpts": {
"allowReturnOutsideFunction": true
},
"sourceMaps": "inline"
}
42 changes: 26 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@

OLDNODETESTS ?= lib/node/test/*.js lib/node/test/node/*.js
NODETESTS ?= test/*.js test/node/*.js
BROWSERTESTS ?= test/*.js test/client/*.js
REPORTER = spec

test:
@if [ "x$(BROWSER)" = "x" ]; then make test-node; else make test-browser; fi
ifeq ("$(OLD_NODE_TEST)", "1")
NODETESTS := $(OLDNODETESTS)
endif

test-node:
@NODE_ENV=test ./node_modules/.bin/nyc ./node_modules/.bin/mocha \
--require should \
--trace-warnings \
--throw-deprecation \
--reporter $(REPORTER) \
--slow 2000 \
--timeout 5000 \
--exit \
$(NODETESTS)
test:
@if [ "$(BROWSER)" = "1" ]; then \
echo test on browser; \
make test-browser; \
fi

test-node-http2:
@NODE_ENV=test HTTP2_TEST=1 node ./node_modules/.bin/mocha \
@if [ "$(NODE_TEST)" = "1" ] || [ "x$(BROWSER)" = "x" ]; then \
echo test on node; \
make test-node; \
fi

copy:
@if [ "$(OLD_NODE_TEST)" = "1" ]; then \
echo test on old node; \
cp test/node/fixtures lib/node/test/node -rf; \
else \
echo test on plain node; \
fi

test-node:copy
@NODE_ENV=test HTTP2_TEST=$(HTTP2_TEST) ./node_modules/.bin/nyc ./node_modules/.bin/mocha \
--require should \
--trace-warnings \
--throw-deprecation \
--reporter $(REPORTER) \
--slow 2000 \
--timeout 5000 \
--exit \
$(NODETESTS)
Expand Down Expand Up @@ -60,4 +70,4 @@ test-docs: docs/head.html docs/tail.html
clean:
rm -fr components

.PHONY: test-cov test docs test-docs clean test-browser-local
.PHONY: copy test-cov test docs test-docs clean test-browser-local
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@
"express-session": "^1.17.2",
"fixpack": "^4.0.0",
"get-port": "4.2.0",
"husky": "^7.0.4",
"marked": "^2.0.0",
"mocha": "6.2.2",
"multer": "^1.4.4",
"nyc": "^15.1.0",
"remark-cli": "^10.0.1",
"remark-preset-github": "^4.0.1",
"rimraf": "^3.0.2",
"should": "^13.2.3",
"should-http": "^0.1.1",
Expand All @@ -73,7 +70,10 @@
"eslint-config-xo-lass": "^1.0.6",
"eslint-plugin-compat": "^4.0.2",
"eslint-plugin-node": "^11.1.0",
"husky": "^7.0.4",
"lint-staged": "^12.4.1",
"remark-cli": "^10.0.1",
"remark-preset-github": "^4.0.1",
"xo": "^0.48.0"
},
"engines": {
Expand Down Expand Up @@ -152,10 +152,11 @@
"scripts": {
"prepare": "husky install",
"browserify": "browserify src/node/index.js -o dist/superagent.js -s superagent -g [ babelify --configFile ./.dist.babelrc ]",
"build": "npm run build:clean && npm run build:lib && npm run build:dist",
"build": "npm run build:clean && npm run build:lib && npm run build:dist && npm run build:test",
"build:clean": "rimraf lib dist",
"build:dist": "npm run browserify && npm run minify",
"build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib",
"build:test": "babel --config-file ./.lib.babelrc test --out-dir lib/node/test",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "eslint -c .eslintrc src test && remark . -qfo && eslint -c .lib.eslintrc lib/**/*.js && eslint -c .dist.eslintrc dist/**/*.js",
"minify": "cross-env NODE_ENV=production browserify src/node/index.js -o dist/superagent.min.js -s superagent -g [ babelify --configFile ./.dist.babelrc ] -p tinyify",
Expand Down
3 changes: 2 additions & 1 deletion test/node/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
const assert = require('assert');
const utils = require('../../lib/utils');
const utils = process.env.OLD_NODE_TEST === '1' ?
require('../../../utils') : require('../../lib/utils');

describe('utils.type(str)', () => {
it('should return the mime type', () => {
Expand Down

0 comments on commit 2fa2541

Please sign in to comment.