This repository has been archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Makefile
127 lines (99 loc) · 2.61 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
##
# Binaries
##
KARMA := node_modules/.bin/karma
##
# Files
##
LIBS = $(shell find lib -type f -name "*.js")
TESTS = $(shell find test -type f -name "*.test.ts")
SUPPORT = $(wildcard karma.conf*.ts)
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.ts
else
KARMA_CONF ?= karma.conf.ts
endif
# Mocha flags.
GREP ?= .
##
# Tasks
##
# Install dependencies.
install:
yarn
# Build typescript
build: clean install
yarn tsc --declaration
.PHONY: build
# Remove temporary files and build artifacts.
clean: test-e2e-clean
rm -rf *.log coverage build
.PHONY: clean
# Remove temporary files, build artifacts, and vendor dependencies.
distclean: clean
rm -rf node_modules
.PHONY: distclean
# Lint JavaScript source files.
lint: install
yarn lint
.PHONY: lint
# Attempt to fix linting errors.
fmt: install
yarn format
.PHONY: fmt
# Run browser unit tests in a browser.
test-browser: build
@$(KARMA) start $(KARMA_FLAGS) $(KARMA_CONF)
.PHONY: test-browser
# Default test target.
test: lint test-browser
.PHONY: test
###
# E2E tests
###
# Commands to start/stop devServer for e2e tests
start_dev_server = (yarn ts-node ./test-e2e/devServer.ts)
stop_dev_server = (pkill SIGTERM ajs-test-e2e-dev-server)
start-dev-server:
$(call start_dev_server)
stop-dev-server:
$(call stop_dev_server) || true
test-e2e-clean:
rm -f ./test-e2e/static/analytics.js
rm -rf ./test-e2e/output
rm -rf ./test-e2e/staging
# Run codecept tests
test-codecept: install stop-dev-server
yarn ts-node ./test-e2e/devServer.ts &
rm -rf ./test-e2e/output
rm -rf ./test-e2e/staging
mkdir ./test-e2e/staging
yarn wait-on http://localhost:8000 && npx codeceptjs run --steps
$(call stop_dev_server)
.PHONY: test-codecept
# Compare recorded network requests from analytics.js against reference requests
# network requests are captured during the codecept tests
test-requests:
TS_NODE_COMPILER_OPTIONS='{"esModuleInterop":true}' yarn mocha -r ts-node/register ./test-e2e/requests.test.ts
.PHONY: test-requests
# Run e2e tests
test-e2e: test-codecept test-requests
.PHONY: test-e2e
# Update the reference data by replacing it with newly generated *.har files in staging directory
test-e2e-update: test-codecept
rm -f ./test-e2e/reference/*.har
cp ./test-e2e/staging/*.har ./test-e2e/reference/
.DEFAULT_GOAL = test