Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tests in docker does not wait for completion #6

Closed
bmz1 opened this issue May 15, 2021 · 13 comments
Closed

Running tests in docker does not wait for completion #6

bmz1 opened this issue May 15, 2021 · 13 comments

Comments

@bmz1
Copy link

bmz1 commented May 15, 2021

Hi!
First of all, thank you for creating this plugin.

From the command line it works great, but I've tried running the tests with docker, and it actually doesn't wait for the tests to complete. I think this is because the vite dev server startup gives back a 0 exit code. This is just a guess though.

Have you tried this plugin in docker? If so, have you faced the same problem?

@betaboon
Copy link
Contributor

hm. I am using it within github-ci which i believe is docker/osi based. could you provide a repro?

@bmz1
Copy link
Author

bmz1 commented May 16, 2021

@betaboon
Copy link
Contributor

@bmz1

adapted from here

diff --git a/Dockerfile b/Dockerfile
index 28b322d..d25fb95 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,12 +14,6 @@ RUN apt-get update \
 ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
 ENV DOCKER=true

-COPY package.json yarn.lock /app/
+RUN npm i puppeteer

-RUN yarn install
-
-COPY . /app/
-
-RUN yarn test
-
-ENTRYPOINT [ "" ]
+CMD ["google-chrome-stable"]
diff --git a/package.json b/package.json
index a6a4067..25f8f0e 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,9 @@
   "scripts": {
     "dev": "vite",
     "build": "vite build",
-    "test": "web-test-runner --coverage"
+    "test": "web-test-runner --coverage",
+    "docker-build": "docker build -t wtr:v1 .",
+    "docker-test": "docker run -i --init --rm -v $(pwd):/app wtr:v1 yarn test"
   },
   "dependencies": {
     "lit-element": "^2.4.0"

@bmz1
Copy link
Author

bmz1 commented May 16, 2021

@betaboon My problem is not running puppeteer, but the following:
test

When I run the tests with the same Dockerfile without the plugin, it waits for the tests to finish.
But somehow it does not wait with the plugin.

@betaboon
Copy link
Contributor

betaboon commented May 16, 2021

tbh I'm not sure if it's the right approach to run the tests in the build-phase of a docker image oO

Edit: i think the main issue here is that during docker build the RUN commands are not run in an interactive-shell, which web-test-runner doesnt seem to like. tbh i think this has nothing to do with this plugin.

Edit2: i just tried to apply the same approach with snowpack. there it somehow works.

@IanVS
Copy link
Contributor

IanVS commented Jun 2, 2021

I'm having this same problem as well, in Github actions.

@betaboon if it's working for you, what versions of web-test-runner and vite are you using?

@betaboon
Copy link
Contributor

betaboon commented Jun 3, 2021

@IanVS that issue/codepath is a nice find. that would completly explain the behavior.
I'm perplexed why it works in my github-actions tho.

"@web/test-runner": "^0.13.3",
"chai": "^4.3.4",
"vite": "^2.2.3",

But i currently don't have the time to look into it. so thank you very much for spending the time and working on a solution :)

@bmz1
Copy link
Author

bmz1 commented Jun 25, 2021

Merged: vitejs/vite#3659

@IanVS
Copy link
Contributor

IanVS commented Jun 25, 2021

@bmz1 after a new version of vite is released, it would be great if you could check that it solves your issue.

@IanVS
Copy link
Contributor

IanVS commented Jun 28, 2021

vite@2.4.0-beta.0 has been released with the referenced PR. Does it solve your problem, @bmz1?

@bmz1
Copy link
Author

bmz1 commented Jun 28, 2021

@IanVS Yes it does 🍾 . Setting ENV CI=true in the Dockerfile solves it. Thanks for your cooperation.

@IanVS
Copy link
Contributor

IanVS commented Jun 28, 2021

🎉 should this issue be closed, then?

@bmz1 bmz1 closed this as completed Jun 28, 2021
@betaboon
Copy link
Contributor

perfect. thank you guys for following up :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants