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

Test built files #551

Merged
merged 29 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4dfd7bc
move build as a prerequisite of test jobs
wheresrhys May 10, 2020
dc39983
separate test job prior to running in deifferent environments
wheresrhys May 10, 2020
eea58a2
rename pipeline
wheresrhys May 10, 2020
cb55678
test cjs build
wheresrhys May 10, 2020
b66cc0c
split out typecheck
wheresrhys May 10, 2020
d906470
fix circle config
wheresrhys May 10, 2020
3ee566d
env -> container
wheresrhys May 10, 2020
432aa78
use workspace effectively
wheresrhys May 10, 2020
b149107
fix attaching workspace
wheresrhys May 10, 2020
c69d2aa
fix path to cjs build
wheresrhys May 10, 2020
a0f3f0e
refactored test runner to allow for being run as esm
wheresrhys May 10, 2020
448b221
streamlined test runner tasks in makefile
wheresrhys May 10, 2020
4029f2c
started using new task names in circle
wheresrhys May 10, 2020
0414f6e
fix circle validation errors
wheresrhys May 10, 2020
37800fd
lint
wheresrhys May 10, 2020
f3581c7
lint .mjs files
wheresrhys May 10, 2020
252de86
fix mistake in server side test refactor
wheresrhys May 10, 2020
0c1fab9
revert attempt to run tests in node6 - too legacy and unsupported
wheresrhys May 10, 2020
6fd55da
theoretically test .mjs files inthe browser
wheresrhys May 10, 2020
007edac
run tests in more versions of node
wheresrhys May 10, 2020
ea937fe
get linting to work in node 12
wheresrhys May 10, 2020
8f01da5
fix running karma tasks in node 12.15+
wheresrhys May 10, 2020
e6d3ec7
alias verify to lint
wheresrhys May 10, 2020
59fbffe
make sure all tests run over built files
wheresrhys May 10, 2020
a965c67
why does mocha not exist when using esm?
wheresrhys May 10, 2020
ac4572d
add esm hook to mocha
wheresrhys May 10, 2020
ad99063
trey and fail to fix testing esm build in mocha;
wheresrhys May 10, 2020
a1baad3
stop trying to get esm tests to pass for now
wheresrhys May 10, 2020
bb525aa
attempt to fix npm releases
wheresrhys May 10, 2020
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
203 changes: 139 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,47 @@ references:
filters:
tags:
only: /.*/
env: &env


nodejs: &nodejs
docker:
- image: circleci/node:12.16.3
browsers: &browsers
docker:
- image: circleci/node:12.16.3-browsers

node14: &node14
docker:
- image: circleci/node:14.2.0
node13: &node13
docker:
- image: circleci/node:13.14.0
node10: &node10
docker:
- image: circleci/node:10.20.1
env-browsers: &env-browsers
node6: &node6
docker:
- image: circleci/node:10.20.1-browsers
- image: circleci/node:6.13.0

workspace: &workspace
attach_workspace:
at: ~/project
persist: &persist
persist_to_workspace:
root: .
paths:
- .

rebuild_test: &rebuild_test
steps:
- *workspace
- run: npm rebuild
- run: FETCH_MOCK_SRC=../cjs/server.js make test


jobs:
checkout_code:
<<: *env
<<: *nodejs
steps:
- checkout
- restore_cache:
Expand All @@ -25,120 +56,164 @@ jobs:
key: npm-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules
- *persist

build:
<<: *nodejs
steps:
- *workspace
- run: make build
- *persist
lint:
<<: *env
<<: *nodejs
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- *workspace
- run: make lint-ci

typecheck:
<<: *nodejs
steps:
- *workspace
- run: make typecheck

test:
<<: *nodejs
steps:
- *workspace
- run: make coverage


nodefetch2:
<<: *env
<<: *nodejs
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- run: make coverage-report
- *workspace
- run: FETCH_MOCK_SRC=../cjs/server.js make test

nodefetch1:
<<: *env
<<: *nodejs
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- *workspace
- run: npm install node-fetch@1
- run: make test-unit
- run: FETCH_MOCK_SRC=../cjs/server.js make test

node6:
docker:
- image: circleci/node:6.13.0
es5:
<<: *node6
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- *workspace
- run: npm rebuild
- run: FETCH_MOCK_SRC=../es5/server.js make test-es5

esm:
<<: *node14
steps:
- *workspace
- run: npm rebuild
- run: make test-node6
- run: make test-esm

node10:
<<: *node10
<<: *rebuild_test
node13:
<<: *node13
<<: *rebuild_test

node14:
<<: *node14
<<: *rebuild_test

chrome:
<<: *env-browsers
<<: *browsers
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- run: make test-chrome
- *workspace
- run: TEST_BROWSER=Chrome make test-browser

firefox:
<<: *env-browsers
<<: *browsers
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- *workspace
- run: npm install karma-firefox-launcher
- run: make test-firefox
- run: TEST_BROWSER=Firefox make test-browser

build:
<<: *env
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- run: make build

deploy:
<<: *env
<<: *nodejs
steps:
- checkout
- restore_cache:
key: npm-cache-{{ checksum "package-lock.json" }}
- run: 'echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ${HOME}/.npmrc'
- *workspace
- run: make publish


workflows:
version: 2
checkout_and_test:
fetch-mock-ci-cd:
jobs:
- checkout_code: *triggerable-by-tag
- nodefetch1:
- test:
<<: *triggerable-by-tag
requires:
- checkout_code
- nodefetch2:
- typecheck:
<<: *triggerable-by-tag
requires:
- checkout_code
- node6:
- lint:
<<: *triggerable-by-tag
requires:
- checkout_code
- chrome:
- build:
<<: *triggerable-by-tag
requires:
- checkout_code
# firefox version too old for sw, so postpone cross browser tests till updated in circleci
# - firefox:
# requires:
# - checkout_code
- lint:
- lint
- test
- nodefetch1:
<<: *triggerable-by-tag
requires:
- checkout_code
- build:
- build
- nodefetch2:
<<: *triggerable-by-tag
requires:
- checkout_code
- build
- es5:
<<: *triggerable-by-tag
requires:
- build
# - esm:
# <<: *triggerable-by-tag
# requires:
# - build
- node10:
<<: *triggerable-by-tag
requires:
- build
- node13:
<<: *triggerable-by-tag
requires:
- build
- node14:
<<: *triggerable-by-tag
requires:
- build
- chrome:
<<: *triggerable-by-tag
requires:
- build
- firefox:
<<: *triggerable-by-tag
requires:
- build
- deploy:
context: wheresrhys-npm-publish
requires:
- nodefetch1
- nodefetch2
- node6
- es5
- chrome
# - firefox
- lint
- firefox
- build
- typecheck
- node10
- node13
- node14
# - esm
filters:
branches:
ignore: /.*/
Expand Down
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['origami-component', 'plugin:prettier/recommended'],
"extends": ["origami-component", "plugin:prettier/recommended"],
"env": {
"browser": true,
"mocha": true,
Expand All @@ -11,8 +11,8 @@ module.exports = {
"globals": {
"expect": true
},
rules: {
'guard-for-in': 0
"rules": {
"guard-for-in": 0
}
}

43 changes: 27 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@ export PATH := $(PATH):./node_modules/.bin

.PHONY: test docs

test-dev:
karma start --browsers=Chrome
SHELL := env "PATH=$(PATH)" /bin/bash
NPM_PUBLISH_TAG := $(shell [[ "$(CIRCLE_TAG)" =~ -[a-z-]+ ]] && echo "pre-release" || echo "latest")
TEST_BROWSER := $(shell [ -z $(TEST_BROWSER) ] && echo "Chrome" || echo ${TEST_BROWSER})

test-chrome:
karma start --single-run --browsers=Chrome
# intended for local dev
test:
mocha test/server.js

test-firefox:
karma start --single-run --browsers=Firefox
test-browser:
@if [ -z $(CI) ]; \
then karma start --browsers=${TEST_BROWSER}; \
else karma start --single-run --browsers=${TEST_BROWSER}; \
fi

test-unit:
mocha test/server.js
test-es5:
node test/es5.js

test-node6: transpile
node test/node6.js
test-esm:
FETCH_MOCK_SRC=../esm/server.js ./node_modules/.bin/mocha test/server.mjs

typecheck:
dtslint --expectOnly types

lint-ci: typecheck
eslint --ignore-pattern test/fixtures/* src test
lint-ci:
eslint --ext .js,.mjs --ignore-pattern test/fixtures/* src test
prettier *.md docs/*.md docs/**/*.md

lint:
eslint --cache --fix --ignore-pattern test/fixtures/* src test
prettier --write *.md docs/*.md docs/**/*.md
eslint --cache --fix --ext .js,.mjs --ignore-pattern test/fixtures/* src test
prettier --cache --write *.md docs/*.md docs/**/*.md

coverage-report:
verify: lint

coverage:
nyc --reporter=lcovonly --reporter=text mocha test/server.js
cat ./coverage/lcov.info | coveralls

Expand All @@ -42,11 +49,15 @@ build: transpile
if [ ! -d "cjs" ]; then mkdir cjs; fi
cp -r src/* cjs
rollup -c rollup.config.js
echo '{"type": "module"}' > esm/package.json

docs:
cd docs; jekyll serve build --watch

NPM_PUBLISH_TAG := $(shell [[ "$(CIRCLE_TAG)" =~ -[a-z-]+ ]] && echo "pre-release" || echo "latest")
la:
@echo $(NPM_PUBLISH_TAG)

publish:
echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ${HOME}/.npmrc
npm version --no-git-tag-version $(CIRCLE_TAG)
npm publish --access public --tag $(NPM_PUBLISH_TAG)
4 changes: 2 additions & 2 deletions docs/_api-mocking/combined-shorthands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |-
The atomic shorthand methods - `.once()`, `any()`, and `.get()`, `.post()`, etc. are combined into a variety of shorthand methods that blend their behaviours.
parametersBlockTitle: Methods
parameters:
- name: Any once
- name: Any once
versionAdded: 9.2.0
content: |-
Create a route that responds to any single request: `.anyOnce(response, options)`
Expand All @@ -17,7 +17,7 @@ parameters:
Create a route that only responds to a single request using a particular http method: `.getOnce()`, `.postOnce()`, `.putOnce()`, `.deleteOnce()`, `.headOnce()`, `.patchOnce()`

- name: Method any

versionAdded: 9.2.0
content: |-
Create a route that responds to any requests using a particular http method: `.getAny()`, `.postAny()`, `.putAny()`, `.deleteAny()`, `.headAny()`, `.patchAny()`
Expand Down
2 changes: 1 addition & 1 deletion docs/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The following request would be matched by all the mocks described below:
fetch('http://example.com/users/bob?q=rita', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: '{"prop1": "val1", "prop2": "val2"}'
body: '{"prop1": "val1", "prop2": "val2"}',
});
```

Expand Down
Loading