Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:8-browsers
- image: circleci/node:14-browsers
steps:
- checkout
- run: npm config set "//registry.npmjs.org/:_authToken" $NPM_AUTH
Expand All @@ -16,7 +16,7 @@ jobs:
TEST_REPORTS_DIR: $CIRCLE_TEST_REPORTS
publish:
docker:
- image: circleci/node:8-browsers
- image: circleci/node:14-browsers
steps:
- checkout
- run: make build
Expand Down
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
##

ESLINT := node_modules/.bin/eslint
ISTANBUL := node_modules/.bin/istanbul
KARMA := node_modules/.bin/karma
MATCHA := node_modules/.bin/matcha
MOCHA := node_modules/.bin/mocha
Expand Down Expand Up @@ -47,20 +46,13 @@ MOCHA_FLAGS := \
--reporter "$(MOCHA_REPORTER)" \
--ui bdd

# Istanbul flags.
COVERAGE_DIR ?= coverage
ISTANBUL_FLAGS := \
--root "./lib" \
--include-all-sources true \
--dir "$(COVERAGE_DIR)/Node $(shell node -v)"

##
# Tasks
##

# Install node modules.
node_modules: package.json $(wildcard node_modules/*/package.json)
@npm install
@npm ci
@touch $@

# Install dependencies.
Expand Down Expand Up @@ -96,7 +88,7 @@ bench: install build

# Run unit tests in node.
test-node: install build
@NODE_ENV=test $(ISTANBUL) cover $(ISTANBUL_FLAGS) $(_MOCHA) -- $(MOCHA_FLAGS) test/render.test.js
@NODE_ENV=test $(_MOCHA) -- $(MOCHA_FLAGS) test/render.test.js
.PHONY: test-node

# Run browser unit tests in a browser.
Expand All @@ -105,6 +97,6 @@ test-browser: install build
.PHONY: test-browser

# Default test target.
test: lint bench test-node test-browser
test: bench test-node test-browser
.PHONY: test
.DEFAULT_GOAL = test
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ Returns the maxified version of the analytics.js snippet given a set of `options
### snippet.min(options)

Returns the minified version of the snippet.


## Development
# Install
```
make install && make build
```
# Run tests:
```
make test-browser
2 changes: 1 addition & 1 deletion karma.conf.ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function(config) {

reporters: ['progress', 'junit', 'coverage'],

browsers: ['PhantomJS'].concat(Object.keys(customLaunchers)),
browsers: Object.keys(customLaunchers),

customLaunchers: customLaunchers,

Expand Down
36 changes: 9 additions & 27 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
/* eslint-env node */
'use strict';
const { chromium } = require('playwright-chromium')

process.env.CHROME_BIN = chromium.executablePath()

module.exports = function(config) {
config.set({
autoWatch: false,
singleRun: true,
files: [
// https://app.segment.com/segment-libraries/sources/snippet/settings/keys
'https://cdn.segment.com/analytics.js/v1/zCueSsEKipbrRgqbJarlTG8UJsAZWpkm/analytics.js',
'test/**/*.test.js'
],

browsers: ['PhantomJS'],
browsers: ['ChromeHeadless'],

frameworks: ['browserify', 'mocha'],

reporters: ['spec', 'coverage'],

reporters: ['spec'],
preprocessors: {
'test/**/*.js': 'browserify'
'test/**/*.js': ['browserify']
},

client: {
mocha: {
grep: process.env.GREP,
Expand All @@ -27,28 +31,6 @@ module.exports = function(config) {
}
},

browserify: {
debug: true,
transform: [
[
'browserify-istanbul',
{
instrumenterConfig: {
embedSource: true
}
}
]
]
},

coverageReporter: {
reporters: [
{ type: 'text' },
{ type: 'html' },
{ type: 'json' }
]
},

plugins: [
'karma-*'
]
Expand Down
Loading