-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Launch each tests in a different runner
- Loading branch information
1 parent
3707d91
commit ea4e62a
Showing
3 changed files
with
77 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,29 @@ | ||
const createTestCafe = require('testcafe') | ||
const runRunner = require('./runner') | ||
const postCommentToGithub = require('./tests/helpers/comment-on-github.js') | ||
|
||
async function runRunner() { | ||
//init vrErrorMsg | ||
process.env.vrErrorMsg = '' | ||
|
||
const tests = [ | ||
//Init data : Unzip archive with files to upload | ||
['testcafe/tests/drive/init-data.js'], | ||
//Tests ! | ||
['testcafe/tests/drive/classification_scenario.js'], | ||
['testcafe/tests/drive/navigation.js'], | ||
['testcafe/tests/drive/folder_sharing_scenario.js'], | ||
['testcafe/tests/drive/file_sharing_scenario.js'], | ||
['testcafe/tests/drive/viewer-feature.js'], | ||
['testcafe/tests/drive/public-viewer-feature.js'], | ||
['testcafe/tests/drive/search.js'], | ||
//cleanup | ||
['testcafe/tests/drive/clean-data.js'] | ||
] | ||
|
||
const runAllTests = async () => { | ||
process.env.vrErrorMsg = '' | ||
if (!process.env.INSTANCE_TESTCAFE || !process.env.TESTCAFE_USER_PASSWORD) { | ||
throw Error( | ||
`You have to provide INSTANCE_TESTCAFE & TESTCAFE_USER_PASSWORD | ||
Exemple: | ||
export INSTANCE_TESTCAFE="cozy.tools:8080" | ||
export TESTCAFE_USER_PASSWORD="foo" ` | ||
) | ||
for (const test of tests) { | ||
await runRunner(test) | ||
} | ||
const tc = await createTestCafe() | ||
const runner = await tc.createRunner() | ||
const response = await runner | ||
.src([ | ||
//Init data : Unzip archive with files to upload | ||
'testcafe/tests/drive/init-data.js', | ||
//Tests ! | ||
'testcafe/tests/drive/classification_scenario.js', | ||
'testcafe/tests/drive/navigation.js', | ||
'testcafe/tests/drive/folder_sharing_scenario.js', | ||
'testcafe/tests/drive/file_sharing_scenario.js', | ||
'testcafe/tests/drive/viewer-feature.js', | ||
'testcafe/tests/drive/public-viewer-feature.js', | ||
'testcafe/tests/drive/search.js', | ||
//cleanup | ||
'testcafe/tests/drive/clean-data.js' | ||
]) | ||
//emulation:cdpPort=9222 is used to set the download folder in headless mode | ||
.browsers(['chrome:headless:emulation:cdpPort=9222 --start-maximized']) | ||
|
||
.screenshots( | ||
'reports/', | ||
true, | ||
'${DATE}_${TIME}/${FIXTURE}/${TEST_ID}-${TEST}/${FILE_INDEX}.png' | ||
) | ||
.run({ | ||
assertionTimeout: 8000, //Testcafe Default value: 3000 | ||
pageLoadTimeout: 6000, //Testcafe Default value: 3000 | ||
selectorTimeout: 15000, //Testcafe Default value: 10000 | ||
skipJsErrors: true, | ||
skipUncaughtErrors: true | ||
}) | ||
tc.close() | ||
|
||
await postCommentToGithub() | ||
|
||
if (response > 0) throw Error(response) | ||
} | ||
|
||
runRunner() | ||
runAllTests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,27 @@ | ||
const createTestCafe = require('testcafe') | ||
const runRunner = require('./runner') | ||
const postCommentToGithub = require('./tests/helpers/comment-on-github.js') | ||
|
||
async function runRunner() { | ||
//init vrErrorMsg | ||
process.env.vrErrorMsg = '' | ||
if (!process.env.INSTANCE_TESTCAFE || !process.env.TESTCAFE_USER_PASSWORD) { | ||
throw Error( | ||
`You have to provide INSTANCE_TESTCAFE & TESTCAFE_USER_PASSWORD | ||
Ex: \n | ||
export INSTANCE_TESTCAFE="cozy.tools:8080" | ||
export TESTCAFE_USER_PASSWORD="foo" ` | ||
) | ||
} | ||
const tc = await createTestCafe() | ||
const runner = await tc.createRunner() | ||
const response = await runner | ||
.src([ | ||
//Scenario that just upload photos, so we don't need to do it in every test. | ||
'testcafe/tests/photos/photos_start_upload_photos.js', | ||
process.env.vrErrorMsg = '' | ||
|
||
'testcafe/tests/photos/photos_crud.js', | ||
'testcafe/tests/photos/album_sharing_scenario.js', | ||
'testcafe/tests/photos/create_empty_album_scenario.js', | ||
'testcafe/tests/photos/create_full_album_scenario.js', | ||
const tests = [ | ||
//Scenario that just upload photos, so we don't need to do it in every test. | ||
['testcafe/tests/photos/photos_start_upload_photos.js'], | ||
|
||
//Scenario that just delete photos, so we don't need to do it in every test. | ||
'testcafe/tests/photos/photos_end_delete_all_data.js' | ||
]) | ||
//emulation:cdpPort=9222 is used to set the download folder in headless mode | ||
.browsers(['chrome:headless:emulation:cdpPort=9222 --start-maximized']) | ||
['testcafe/tests/photos/photos_crud.js'], | ||
['testcafe/tests/photos/album_sharing_scenario.js'], | ||
['testcafe/tests/photos/create_empty_album_scenario.js'], | ||
['testcafe/tests/photos/create_full_album_scenario.js'], | ||
|
||
.screenshots( | ||
'reports/', | ||
true, | ||
'${DATE}_${TIME}/${FIXTURE}/${TEST_ID}-${TEST}/${FILE_INDEX}.png' | ||
) | ||
.run({ | ||
assertionTimeout: 8000, //Testcafe Default value: 3000 | ||
pageLoadTimeout: 6000, //Testcafe Default value: 3000 | ||
selectorTimeout: 15000, //Testcafe Default value: 10000 | ||
skipJsErrors: true, | ||
skipUncaughtErrors: true | ||
}) | ||
tc.close() | ||
//Scenario that just delete photos, so we don't need to do it in every test. | ||
'testcafe/tests/photos/photos_end_delete_all_data.js' | ||
] | ||
|
||
await postCommentToGithub() | ||
const runAllTests = async () => { | ||
process.env.vrErrorMsg = '' | ||
for (const test of tests) { | ||
await runRunner(test) | ||
} | ||
|
||
if (response > 0) throw Error(response) | ||
await postCommentToGithub() | ||
} | ||
|
||
runRunner() | ||
runAllTests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const createTestCafe = require('testcafe') | ||
|
||
module.exports = async function(testsArray) { | ||
//init vrErrorMsg | ||
process.env.vrErrorMsg = '' | ||
if (!process.env.INSTANCE_TESTCAFE || !process.env.TESTCAFE_USER_PASSWORD) { | ||
throw Error( | ||
`You have to provide INSTANCE_TESTCAFE & TESTCAFE_USER_PASSWORD | ||
Exemple: | ||
export INSTANCE_TESTCAFE="cozy.tools:8080" | ||
export TESTCAFE_USER_PASSWORD="foo" ` | ||
) | ||
} | ||
const tc = await createTestCafe() | ||
const runner = await tc.createRunner() | ||
const response = await runner | ||
.src(testsArray) | ||
//emulation:cdpPort=9222 is used to set the download folder in headless mode | ||
.browsers(['chrome:emulation:cdpPort=9222 --start-maximized']) | ||
|
||
.screenshots( | ||
'reports/', | ||
true, | ||
'${DATE}_${TIME}/${FIXTURE}/${TEST_ID}-${TEST}/${FILE_INDEX}.png' | ||
) | ||
.run({ | ||
assertionTimeout: 8000, //Testcafe Default value: 3000 | ||
pageLoadTimeout: 6000, //Testcafe Default value: 3000 | ||
selectorTimeout: 15000, //Testcafe Default value: 10000 | ||
skipJsErrors: true, | ||
skipUncaughtErrors: true | ||
}) | ||
tc.close() | ||
|
||
if (response > 0) throw Error(response) | ||
} |