Reputation: 11
I'm new into TestCafe
and I'm trying to write a dockerfile using testcafe image.
In testcafe documentation, they say I have to pass the File-or-glob ...
argument, which specifies the files or directories (separated by a space) from which to run the tests.
The problem is that I use a generic runner, which gets a fixture name, and then execute its test, on demand, when ever the user asks for a screenshot.
That is why I'm confused what to put in the docker run command, I thought it should be the runner file.
Runner:
const takeScreenShot = async(fixtureName:string, testName:string) =>{
const testCafe= await createTestCafe('localhost');
try{
const runner = testCafe.createRunner();
await runner
.src(`src/testcafe-automations/${fixtureName}.ts`)
.filter(testRequested=>testRequested===testName)
.browsers('chromiuim:headless')
.screenshots({fullPage:true, path: screenshotsPath})
.run()
}
}
docker command:
$ docker run -v ${PWD}:/tests -it --entrypoint node testcafe/testcafe 'chromium:headless --no-sandbox' '/tests/src/testcafe-automations/utils/runner-file.ts'
This is a node project, and I'm not sure if I even need this in my docker, I was also wondering of using in circleCI
image. The only thing I need is taking screenshots.
Upvotes: 1
Views: 225
Reputation: 711
By default, when you use docker run
to start TestCafe docker image, it just passes specified arguments to the testcafe
command in the container. If you are using a Runner
object, use node
to run the script that uses it.
Since you've already overwritten the default entrypoint with the node
executable, you can pass the name of the runner script and the fixture name as arguments:
docker run -v ${PWD}:/tests -it --entrypoint node testcafe/testcafe '/tests/src/testcafe-automations/utils/runner.js' 'fixtureName'
In the runner.js
, you should call your function with command-line arguments passed to Node.js (read them by using process.argv)
Upvotes: 1