#Help me to find a Docker image to run my tests in Gitlab CI

58 messages Β· Page 1 of 1 (latest)

karmic forge
#

Hi people πŸ–οΈ. Does anyone had a good Docker image to run Angular unit tests with the famous npm test -- --no-watch --no-progress --browsers=ChromeHeadless ?

I have experienced a bunch like timbru31/node-chrome, cypress/browsers and weboaks/node-karma-protractor-chrome but all of them requires to override karma config to add --no-sandox. I would like to rely only on Angular default karma config

opal phoenix
#

It looks expected when u want to use headless.

#

And I think it's unrelated to the docker image.

#

I think it's fairly common to have CI specific test-runner-configuration.

#

So u can do:

npm run test
npm run test:ci
karmic forge
#

I would like to not be forced to ng g config karma in order to run my tests in CI. The --no-sandbox flag is only mandatory because of root user.

opal phoenix
#

I think having a CI specific config is less work than trying to fix this on the docker level.

#

The best you can do is create a non-root user I guess, which has additional complications.

karmic forge
#

Since I have been working with Angular I always have a specific config for CI but today I wonder, am I do it right ? Is there a way to simplify it ? The only additional config I need to run my tests is the "--no-sandbox" flag. A whole config file just for a flag caused by the use of "root" user... I though it was overkill or sort of

opal phoenix
karmic forge
#

But maybe I'm wrong, and as you said it's more complicated to fix the docker side

opal phoenix
#

Anyway, --no-sandbox for running tests against ChronmeHeadless in docker is 100% expected and very very common. Sure, ways around it I guess, but not the typical (and correct) solution.

#

A whole config file just for a flag caused by the use of "root" user... I though it was overkill or sort of

Trying to find a whole new docker image, just to avoid setting a flag that is expected, that sounds overkill.

#

The flag is unrelated to karma, but to chrome.

#

U can also not run in Chrome πŸ˜„

karmic forge
#

Ya I guess.
Talking about docker image, do you have a recommandation for one with nodejs and chrome ?

karmic forge
opal phoenix
#

As long as u use the 18 one

#

But I havent used it tho, sorry.

#

I prefer testing against more than just chrome πŸ˜„

karmic forge
#

Yes yes, my problem today is I can no longer rely on cypress/broswers as they use 20 for the latest chrome versions

opal phoenix
#

U can always pin versions

karmic forge
#

Yes but If i want to stick to node 18, the available chrome versions are not the latests

opal phoenix
#

Yeah thats an issue you always have when relying on others.

#

Could just roll your own dockerfile.

karmic forge
karmic forge
karmic forge
#

You may want to test your app on the most recent browser and so build a docker image on each chrome release (which is quiet often these days)

opal phoenix
#

I think u want to use things like browserstack.

#

But regardless u can have full control over all versions when u use your own dockerfile

#

Either always use the latest

#

or pin it.

#

With Chrome, u should be okay to have a dockerfile that sticks to node 18 and installs the latest chrome on every CI run.

karmic forge
#

Like using a node:18 image and manually install chrome before running tests ?

opal phoenix
#

yes

#

Which are the same lines as in the link I shared

karmic forge
#

Maybe it's a noob question but, you can base a CI job on a Dockerfile ?

opal phoenix
#

(could just use that dockerfile tho, I assume it sticks to 18)

#

Yeah u push to the gitlab registry.

#

Probably not worth it here tho, just use the one I linked.

karmic forge
#

Ah yes I get it. Actually the back-end team of my company use homemade docker images in their tests (using gitlab registry) and it's fine as their dependencies are fixed. On my front-end side, I would like to be sure that the app works well on the latest chrome versions (https://docs.angular.lat/guide/browser-support) and it's challenging to archive this goal without building countless images that's why I chose to rely on dockerhub to find pre-made image that fit my needs

opal phoenix
#

I honestly still do not understand what u mean with building countless images.

#

Just ensure to install the latest chrome everytime the container starts

#

And u use the latest chrome automatically

karmic forge
#

If today google release chrome X, I have to build an image with X
If tomorrow google release chrome X+1, repeat

opal phoenix
#

No.

#

But sure πŸ˜„

karmic forge
#

I guess I didn't take enough step back to realize that I just need to install chrome will I'm running my tests instead of using a pre-made Docker image...

#

Just wanted to make my CI job fast XD

opal phoenix
#

Yeha you cant have everything.

#

Either u use a fixed version and optimize

#

or u use the latest version and suffer some hits.

karmic forge
#

Words of wisdom XD