Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit f319c60

Browse files
committed
Pull request #39: chore(e2e): playwright instead of puppeteer
Merge in WS/iink-js from playwright to master * commit '25c39df140cc212f84395b450f1155cc0f73b6cd': chore(e2e): playwright instead of puppeteer
2 parents e7f245a + 25c39df commit f319c60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+65967
-571753
lines changed

.mocharc.e2e.env.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
process.env.LAUNCH_URL = process.env.LAUNCH_URL || 'http://localhost:8080'
2+
process.env.HEADLESS = true
3+
process.env.BROWSER = process.env.BROWSER || 'chromium'

.mocharc.e2e.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
exit: false,
3+
recursive: true,
4+
spec: './test/playwright/*.spec.js',
5+
require: '.mocharc.e2e.env.js,./test/playwright/helper/mochaHooks.js',
6+
timeout: 30000,
7+
parallel: false,
8+
reporter: 'spec'
9+
}

Jenkinsfile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,39 @@ pipeline {
3030
}
3131
}
3232

33-
stage ('test'){
33+
stage ('init_examples'){
3434
steps {
35-
sh "make ${env.MAKE_ARGS} test-e2e"
35+
sh "make ${env.MAKE_ARGS} init_examples"
3636
}
3737
}
3838

39+
stage('test browser') {
40+
41+
failFast false
42+
43+
parallel {
44+
45+
stage ('test-chromium'){
46+
steps {
47+
sh "BROWSER=chromium make ${env.MAKE_ARGS} test-e2e"
48+
}
49+
}
50+
51+
stage ('test-webkit'){
52+
steps {
53+
sh "BROWSER=webkit make ${env.MAKE_ARGS} test-e2e"
54+
}
55+
}
56+
57+
stage ('test-firefox'){
58+
steps {
59+
sh "BROWSER=firefox make ${env.MAKE_ARGS} test-e2e"
60+
}
61+
}
62+
}
63+
64+
}
65+
3966
stage ('audit'){
4067
steps {
4168
sh "npm audit --production"

Makefile

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ clean: ## Remove all produced binaries.
1212
@rm -rf docs
1313

1414
prepare: ## Install all dependencies.
15-
@PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install
15+
@PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install
1616

1717
build: clean ## Building the dist files from sources.
1818
@npm run build
@@ -26,40 +26,55 @@ docker: build ## Build the docker image containing last version of myscript-js a
2626
@cp -R dist docker/examples/delivery/
2727
@cp -R examples docker/examples/delivery/
2828
@cp -R node_modules docker/examples/delivery/
29-
@cd docker/examples/ && docker build --build-arg applicationkey=${DEV_APPLICATIONKEY} --build-arg hmackey=${DEV_HMACKEY} $(DOCKER_PARAMETERS) -t $(EXAMPLES_DOCKERREPOSITORY) .
29+
@cd docker/examples/ && \
30+
docker build \
31+
--build-arg applicationkey=${DEV_APPLICATIONKEY} \
32+
--build-arg hmackey=${DEV_HMACKEY} $(DOCKER_PARAMETERS) -t $(EXAMPLES_DOCKERREPOSITORY) .
3033

3134
killdocker:
3235
@docker ps -a | grep "iinkjs-$(DOCKERTAG)-$(BUILDENV)-" | awk '{print $$1}' | xargs -r docker rm -f 2>/dev/null 1>/dev/null || true
3336

34-
test-e2e: killdocker _examples
35-
docker pull $(PUPPETEER_DOCKERREPOSITORY)
36-
if [[ $(DEVLOCAL) == true ]]; then \
37+
38+
local-test-e2e: init_examples
39+
@$(MAKE) BROWSER=$(BROWSER) test-e2e
40+
41+
test-e2e:
42+
@if [[ $(DEVLOCAL) == true ]]; then \
3743
EXAMPLES_IP=localhost; \
3844
else \
3945
EXAMPLES_IP=$$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME)); \
4046
fi && \
4147
docker run -i --rm \
4248
-v $(CURRENT_PWD):/tests \
4349
-e LAUNCH_URL="http://$${EXAMPLES_IP}:$(EXAMPLES_LISTEN_PORT)" \
44-
--user=$(CURRENT_USER_UID) \
45-
--userns=host \
46-
--net=host \
47-
$(PUPPETEER_DOCKERREPOSITORY)
50+
-e BROWSER=$(BROWSER) \
51+
--ipc=host \
52+
-w "/tests" \
53+
--name "playwright-$(BROWSER)" mcr.microsoft.com/playwright:bionic \
54+
npm run test:e2e
4855

4956
dev-all: dev-examples ## Launch all the requirements for launching tests.
5057

51-
dev-examples: _examples ## Launch a local nginx server to ease development.
58+
dev-examples: init_examples ## Launch a local nginx server to ease development.
5259

53-
_examples:
60+
_launch_examples:
5461
@echo "Starting examples container!"
55-
docker run -d --name $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME) $(DOCKER_EXAMPLES_PARAMETERS) \
62+
@docker run -d \
5663
-e "LISTEN_PORT=$(EXAMPLES_LISTEN_PORT)" \
57-
-e "APISCHEME=$(APISCHEME)" \
64+
-e "APISCHEME=$(APISCHEME)" \
5865
-e "APIHOST=$(APIHOST)" \
59-
-e "APPLICATIONKEY=$(DEV_APPLICATIONKEY)" \
60-
-e "HMACKEY=$(DEV_HMACKEY)" \
61-
$(EXAMPLES_DOCKERREPOSITORY)
62-
@docker run --rm --link $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME):WAITHOST -e "WAIT_PORT=$(EXAMPLES_LISTEN_PORT)" -e "WAIT_SERVICE=Test examples" $(WAITTCP_DOCKERREPOSITORY)
66+
-e "APPLICATIONKEY=$(DEV_APPLICATIONKEY)" \
67+
-e "HMACKEY=$(DEV_HMACKEY)" \
68+
$(DOCKER_EXAMPLES_PARAMETERS) \
69+
--name $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME) $(EXAMPLES_DOCKERREPOSITORY)
70+
_check_examples:
71+
@docker run --rm \
72+
--link $(TEST_DOCKER_EXAMPLES_INSTANCE_NAME):WAITHOST \
73+
-e "WAIT_PORT=$(EXAMPLES_LISTEN_PORT)" \
74+
-e "WAIT_SERVICE=Test examples" \
75+
$(WAITTCP_DOCKERREPOSITORY)
76+
@echo "Examples started!"
77+
init_examples: _launch_examples _check_examples
6378

6479
help: ## This help.
6580
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

Makefile.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ EXAMPLES_DOCKERREPOSITORY = $(REGISTRY)/iinkjs-examples:$(DOCKERTAG)
3232
CONFIGURATION_DOCKERTAG := master
3333
MOCHA_DOCKERREPOSITORY = $(REGISTRY)/myscript-webcomponents-mocha:$(CONFIGURATION_DOCKERTAG)
3434
WAITTCP_DOCKERREPOSITORY = $(REGISTRY)/myscript-webcomponents-wait-tcp:$(CONFIGURATION_DOCKERTAG)
35-
PUPPETEER_DOCKERREPOSITORY = $(REGISTRY)/myscript-common-puppeteer:1.0.0
3635

3736
BUILDENV := test
3837
TEST_DOCKER_NAME_PREFIX := iinkjs-$(DOCKERTAG)-$(BUILDENV)-$(BUILDID)
@@ -41,6 +40,9 @@ TEST_DOCKER_EXAMPLES_INSTANCE_NAME := $(TEST_DOCKER_NAME_PREFIX)-examples
4140
APPLICATIONKEY := 7d223f9e-a3cb-4213-ba4b-85e930605f8b
4241
HMACKEY := 5ab1935e-529a-4d48-a695-158450e52b13
4342

43+
DEV_APPLICATIONKEY := 515131ab-35fa-411c-bb4d-3917e00faf60
44+
DEV_HMACKEY := 54b2ca8a-6752-469d-87dd-553bb450e9ad
45+
4446
APIHOST := cloud-internal-master.corp.myscript.com
4547
APISCHEME := https
4648
ifeq ($(CDKAPILOCAL),true)

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@rollup/plugin-babel": "^5.0.0",
4343
"@rollup/plugin-json": "^4.0.2",
4444
"@rollup/plugin-node-resolve": "^6.1.0",
45-
"chai": "^4.2.0",
45+
"chai": "^4.3.4",
4646
"clean-css-cli": "^4.3.0",
4747
"eslint": "^6.8.0",
4848
"eslint-config-standard": "^14.1.1",
@@ -51,26 +51,31 @@
5151
"eslint-plugin-promise": "^4.2.1",
5252
"eslint-plugin-standard": "^4.0.1",
5353
"minami": "^1.2.3",
54-
"mocha": "^8.1.3",
54+
"mocha": "^9.0.3",
5555
"npm-run-all": "^4.1.5",
56+
"playwright": "^1.14.0",
5657
"postcss-import": "^12.0.1",
57-
"puppeteer": "^2.1.1",
5858
"rollup": "^2.18.0",
5959
"rollup-plugin-commonjs": "^10.1.0",
6060
"rollup-plugin-livereload": "^1.2.0",
6161
"rollup-plugin-postcss": "^2.6.2",
6262
"rollup-plugin-progress": "^1.1.1",
6363
"rollup-plugin-serve": "^1.0.1",
6464
"rollup-plugin-terser": "^7.0.1",
65-
"sinon": "^2.4.1"
65+
"sinon": "^2.4.1",
66+
"taffydb": "^2.7.3"
6667
},
6768
"scripts": {
6869
"lint": "eslint --ext js src",
70+
"lint:test": "eslint --ext js test",
6971
"docs": "npx jsdoc -R README.md -P '' -d docs -t node_modules/minami -r src",
7072
"minify-css": "cleancss -o dist/iink.min.css src/*.css",
7173
"test:mocha": "mocha --require @babel/register,./test/lib/common.js --recursive test/mocha/ --reporter progress",
7274
"test:mocha-xunit": "mocha --require @babel/register --recursive test/mocha/ --reporter xunit --reporter-options output=./test/mocha/results/xunit.xml",
73-
"test:e2e": "mocha --require @babel/register,test/puppeteer/base.js --recursive test/puppeteer --timeout 30000 --retries 2 --parallel",
75+
"test:e2e": "mocha --config .mocharc.e2e.js",
76+
"test:chromium": "BROWSER=chromium mocha --config .mocharc.e2e.js",
77+
"test:webkit": "BROWSER=webkit mocha --config .mocharc.e2e.js",
78+
"test:firefox": "BROWSER=firefox mocha --config .mocharc.e2e.js",
7479
"build:js": "rollup -c config/rollup.config.build.js --sourcemap",
7580
"build": "npm-run-all test:mocha lint build:js minify-css docs",
7681
"dev:js": "rollup -c config/rollup.config.dev.js -w --sourcemap",

test/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
},
55
globals: {
66
browser: true,
7+
page: true,
78
expect: true
89
}
910
}

0 commit comments

Comments
 (0)