Angular test can not run with headless chrome in docker

I have built an angular project on my loaclhost, now what I neeed is to test this project in the docker, and finally I want to realize continuous integration.

I have learned from here, and tried to run the command
ng test --watch=false --browsers=ChromeHeadless
Then I am getting a few errors.

Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted

It is suggested to run the app as a user made in the Docker file. But, when I add that user, the user gets the error mentioned above.

Then when I try and run the application as root, I get a new error,

Running as root without --no-sandbox is not supported.

I have searched several ways to solve this problem, and I have succeeded when I changed the file karma.conf.js in the project.

However, for some reason, I should not change the files in the project, so how can I solve this problem?

I except the command
ng test --watch=false --browsers=ChromeHeadless
can be run with no error in the docker, and the files in the project can not be edited.

Source: StackOverflow