Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
- show output of failed tests
- ensure Docker images are not pulled in tests
  • Loading branch information
tyranron committed Nov 1, 2022
1 parent 041f264 commit c0afa4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ test: test.docker
# Docker commands #
###################

docker-registries = $(strip $(if $(call eq,$(registries),),\
$(REGISTRIES),$(subst $(comma), ,$(registries))))
docker-tags = $(strip $(if $(call eq,$(tags),),\
$(TAGS),$(subst $(comma), ,$(tags))))
docker-registries = $(strip \
$(or $(subst $(comma), ,$(registries)),$(REGISTRIES)))
docker-tags = $(strip $(or $(subst $(comma), ,$(tags)),$(TAGS)))


# Build Docker image with the given tag.
Expand Down Expand Up @@ -180,6 +179,7 @@ endif
IMAGE=$(OWNER)/$(NAME):$(or $(tag),$(VERSION)) \
node_modules/.bin/bats \
--timing $(if $(call eq,$(CI),),--pretty,--formatter tap) \
--print-output-on-failure \
tests/main.bats


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"devDependencies": {
"bats": "^1.1"
"bats": "^1.8"
}
}
16 changes: 10 additions & 6 deletions tests/main.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@


@test "Firefox is installed" {
run docker run --rm --entrypoint sh $IMAGE -c 'test -f /opt/firefox/firefox'
run docker run --rm --pull never --entrypoint sh $IMAGE -c \
'test -f /opt/firefox/firefox'
[ "$status" -eq 0 ]
}

@test "Firefox runs ok" {
run docker run --rm --entrypoint sh $IMAGE -c '/opt/firefox/firefox --help'
run docker run --rm --pull never --entrypoint sh $IMAGE -c \
'/opt/firefox/firefox --help'
[ "$status" -eq 0 ]
}

Expand All @@ -17,7 +19,7 @@
[ ! "$output" = '' ]
expected="$output"

run docker run --rm -e MOZ_HEADLESS=0 --entrypoint sh $IMAGE -c \
run docker run --rm --pull never -e MOZ_HEADLESS=0 --entrypoint sh $IMAGE -c \
"/opt/firefox/firefox -v"
[ "$status" -eq 0 ]
[ ! "$output" = '' ]
Expand All @@ -28,12 +30,14 @@


@test "geckodriver is installed" {
run docker run --rm --entrypoint sh $IMAGE -c 'which geckodriver'
run docker run --rm --pull never --entrypoint sh $IMAGE -c \
'which geckodriver'
[ "$status" -eq 0 ]
}

@test "geckodriver runs ok" {
run docker run --rm --entrypoint sh $IMAGE -c 'geckodriver --help'
run docker run --rm --pull never --entrypoint sh $IMAGE -c \
'geckodriver --help'
[ "$status" -eq 0 ]
}

Expand All @@ -43,7 +47,7 @@
[ ! "$output" = '' ]
expected="$output"

run docker run --rm --entrypoint sh $IMAGE -c \
run docker run --rm --pull never --entrypoint sh $IMAGE -c \
"geckodriver -V | grep -m 1 geckodriver | cut -d ' ' -f2"
[ "$status" -eq 0 ]
[ ! "$output" = '' ]
Expand Down

0 comments on commit c0afa4f

Please sign in to comment.