-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modernize test harness; remove Duo support, add Browserify support
- Loading branch information
Showing
16 changed files
with
321 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
{ | ||
"extends": "segment/browser", | ||
|
||
"rules": { | ||
"global-strict": 0, | ||
"max-len": 0, | ||
"strict": 1 | ||
}, | ||
|
||
"globals": { | ||
"exports": true, | ||
"module": true, | ||
"require": true | ||
} | ||
"extends": "@segment/eslint-config/browser/legacy" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
*.log | ||
.DS_Store | ||
build.js | ||
components | ||
coverage | ||
node_modules |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,80 @@ | ||
# | ||
# Binaries. | ||
# | ||
|
||
DUO = node_modules/.bin/duo | ||
DUOT = node_modules/.bin/duo-test | ||
ESLINT = node_modules/.bin/eslint | ||
|
||
# | ||
# Files. | ||
# | ||
|
||
SRCS_DIR = lib | ||
SRCS = $(shell find $(SRCS_DIR) -type f -name "*.js") | ||
TESTS_DIR = test | ||
TESTS = $(shell find $(TESTS_DIR) -type f -name '*.test.js') | ||
|
||
# | ||
# Task config. | ||
# | ||
|
||
BROWSER ?= chrome | ||
|
||
PORT ?= 0 | ||
|
||
DUOT_ARGS = \ | ||
--reporter spec \ | ||
--port $(PORT) \ | ||
--commands "make build" | ||
|
||
# | ||
# Chore tasks. | ||
# | ||
|
||
# Install node dependencies. | ||
## | ||
# Binaries | ||
## | ||
|
||
ESLINT := node_modules/.bin/eslint | ||
KARMA := node_modules/.bin/karma | ||
|
||
## | ||
# Files | ||
## | ||
|
||
LIBS = $(shell find lib -type f -name "*.js") | ||
TESTS = $(shell find test -type f -name "*.test.js") | ||
SUPPORT = $(wildcard karma.conf*.js) | ||
ALL_FILES = $(LIBS) $(TESTS) $(SUPPORT) | ||
|
||
## | ||
# Program options/flags | ||
## | ||
|
||
# A list of options to pass to Karma | ||
# Overriding this overwrites all options specified in this file (e.g. BROWSERS) | ||
KARMA_FLAGS ?= | ||
|
||
# A list of Karma browser launchers to run | ||
# http://karma-runner.github.io/0.13/config/browsers.html | ||
BROWSERS ?= | ||
ifdef BROWSERS | ||
KARMA_FLAGS += --browsers $(BROWSERS) | ||
endif | ||
|
||
ifdef CI | ||
KARMA_CONF ?= karma.conf.ci.js | ||
else | ||
KARMA_CONF ?= karma.conf.js | ||
endif | ||
|
||
# Mocha flags. | ||
GREP ?= . | ||
|
||
## | ||
# Tasks | ||
## | ||
|
||
# Install node modules. | ||
node_modules: package.json $(wildcard node_modules/*/package.json) | ||
@npm install | ||
@touch $@ | ||
|
||
# Install dependencies. | ||
install: node_modules | ||
|
||
# Remove temporary files and build artifacts. | ||
clean: | ||
rm -rf build.js | ||
rm -rf *.log coverage | ||
.PHONY: clean | ||
|
||
# Remove temporary files, build artifacts, and vendor dependencies. | ||
distclean: clean | ||
rm -rf components node_modules | ||
rm -rf node_modules | ||
.PHONY: distclean | ||
|
||
# | ||
# Build tasks. | ||
# | ||
|
||
# Build all integrations, tests, and dependencies together for testing. | ||
build.js: node_modules component.json $(SRCS) $(TESTS) | ||
@$(DUO) --stdout --development $(TESTS) > $@ | ||
|
||
# Build shortcut. | ||
build: build.js | ||
.DEFAULT_GOAL = build | ||
|
||
# | ||
# Test tasks. | ||
# | ||
|
||
# Lint JavaScript source. | ||
lint: node_modules | ||
@$(ESLINT) $(SRCS) $(TESTS) | ||
# Lint JavaScript source files. | ||
lint: install | ||
@$(ESLINT) $(ALL_FILES) | ||
.PHONY: lint | ||
|
||
# Test locally in PhantomJS. | ||
test-phantomjs: node_modules build.js | ||
@$(DUOT) phantomjs $(TESTS_DIR) args: \ | ||
--path node_modules/.bin/phantomjs | ||
.PHONY: test | ||
# Attempt to fix linting errors. | ||
fmt: install | ||
@$(ESLINT) --fix $(ALL_FILES) | ||
.PHONY: fmt | ||
|
||
# Run browser unit tests in a browser. | ||
test-browser: install | ||
@$(KARMA) start $(KARMA_FLAGS) $(KARMA_CONF) | ||
|
||
# Test locally in the browser. | ||
test-browser: node_modules build.js | ||
@$(DUOT) browser --commands "make build" $(TESTS_DIR) | ||
.PHONY: test-browser | ||
|
||
# Test in Sauce Labs. Note that you must set the SAUCE_USERNAME and | ||
# SAUCE_ACCESS_KEY environment variables using your Sauce Labs credentials. | ||
test-sauce: node_modules build.js | ||
@$(DUOT) saucelabs $(TESTS_DIR) \ | ||
--name analytics.js-integrations \ | ||
--browsers $(BROWSER) \ | ||
--user $(SAUCE_USERNAME) \ | ||
--key $(SAUCE_ACCESS_KEY) | ||
.PHONY: test-sauce | ||
|
||
# Test shortcut. | ||
test: lint test-phantomjs | ||
# Default test target. | ||
test: lint test-browser | ||
.PHONY: test | ||
.DEFAULT_GOAL = test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
machine: | ||
node: | ||
version: 0.12 | ||
version: 4 | ||
environment: | ||
NPM_CONFIG_PROGRESS: false | ||
NPM_CONFIG_SPIN: false | ||
TEST_REPORTS_DIR: $CIRCLE_TEST_REPORTS | ||
|
||
dependencies: | ||
pre: | ||
- echo "github.com,192.30.252.*,192.30.253.*,192.30.254.*,192.30.255.* ssh-rsa $(ssh-keyscan -t rsa github.com | cut -d ' ' -f 3-)" >> ~/.ssh/known_hosts | ||
- npm install -g npm@'>=2.7.0' | ||
- make | ||
- npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH | ||
- npm -g install codecov | ||
override: | ||
- make install | ||
|
||
test: | ||
override: | ||
- make test | ||
post: | ||
- cp -R coverage $CIRCLE_ARTIFACTS/ | ||
- codecov | ||
|
||
deployment: | ||
publish: | ||
owner: segmentio | ||
# Works on e.g. `1.0.0-alpha.1` | ||
tag: /[0-9]+(\.[0-9]+)*(-.+)?/ | ||
commands: | ||
- npm publish . |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
var baseConfig = require('./karma.conf'); | ||
|
||
var customLaunchers = { | ||
sl_chrome_latest: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
platform: 'linux', | ||
version: 'latest' | ||
}, | ||
sl_chrome_latest_1: { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
platform: 'linux', | ||
version: 'latest-1' | ||
}, | ||
sl_firefox_latest: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'linux', | ||
version: 'latest' | ||
}, | ||
sl_firefox_latest_1: { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'linux', | ||
version: 'latest-1' | ||
}, | ||
sl_safari_9: { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
version: '9.0' | ||
}, | ||
// FIXME(ndhoule): Bad IE7/8 support in testing packages make these fail | ||
// sl_ie_7: { | ||
// base: 'SauceLabs', | ||
// browserName: 'internet explorer', | ||
// version: '7' | ||
// }, | ||
// sl_ie_8: { | ||
// base: 'SauceLabs', | ||
// browserName: 'internet explorer', | ||
// version: '8' | ||
// }, | ||
sl_ie_9: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
version: '9' | ||
}, | ||
sl_ie_10: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
version: '10' | ||
}, | ||
sl_ie_11: { | ||
base: 'SauceLabs', | ||
browserName: 'internet explorer', | ||
version: '11' | ||
}, | ||
sl_edge_latest: { | ||
base: 'SauceLabs', | ||
browserName: 'microsoftedge' | ||
} | ||
}; | ||
|
||
module.exports = function(config) { | ||
baseConfig(config); | ||
|
||
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) { | ||
throw new Error('SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are required but are missing'); | ||
} | ||
|
||
config.set({ | ||
browserDisconnectTolerance: 1, | ||
|
||
singleRun: true, | ||
|
||
reporters: ['progress', 'junit', 'coverage'], | ||
|
||
browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)), | ||
|
||
customLaunchers: customLaunchers, | ||
|
||
junitReporter: { | ||
outputDir: process.env.TEST_REPORTS_DIR, | ||
suite: require('./package.json').name | ||
}, | ||
|
||
sauceLabs: { | ||
testName: require('./package.json').name | ||
}, | ||
|
||
coverageReporter: { | ||
reporters: [ | ||
{ type: 'lcov' } | ||
] | ||
} | ||
}); | ||
}; |
Oops, something went wrong.