TestCafe 'dynamic' tests cases
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I created a few e2e sanity tests for my current project using TestCafe. These tests are standard TestCafe tests:
fixture(`Basic checkout flow`)
test('Main Flow', async (t) =>
);
I would like to execute this test for multiple site locales and for multiple channels. i.e. I need this test to run for nl_nl, nl_be, en_gb, .. and also for channels like b2c, b2b, ...
The easiest way is to create a loop in the test itself to loop over the locales and channels, but I want to run these test concurrently.
I tried to create a function to dynamically generate these tests, but TestCafe cant seem to detect the tests then.
dynamicTest('Main Flow', async (t) =>
);
function dynamicTest(testName, testFn) =>
const channels = ['b2c']
channels.forEach((channel) =>
test(`[Channel] $channel] $testName`, testFn);
);
;
Is there a better way for doing this? The only solution I see is running the test script multiple times from jenkins to have concurrency.
more detailed code:
import HomePage from '../../page/HomePage/HomePage';
import EnvUtil from '../../util/EnvUtil';
const wrapper = (config, testFn) =>
config.locales.forEach(async locale =>
config.channels.forEach(async channel =>
const tstConfig =
locale,
channel
;
tstConfig.env = EnvUtil.parse(tstConfig, config.args.env);
testConfig.foo = await EnvUtil.get() // If I remove this line it works!
testFn(config, locale, channel)
)
);
;
fixture(`[Feature] Feature 1`)
.beforeEach(async t =>
t.ctx.pages =
home: new HomePage(),
... more pages here
;
);
wrapper(global.config, (testConfig, locale, channel) =>
test
.before(async (t) =>
t.ctx.config = testConfig;
)
.page(`foo.bar.com`)
(`[Feature] [Locale: $locale.key] [Channel: $channel.key] Feature 1`, async (t) =>
await t.ctx.pages.home.header.search(t, '3301');
.. more test code here
);
);
If I run it like this I get a "test is undefined" error. Is there something wrong in the way i'm wrapping "test"?
e2e-testing testcafe
|
show 1 more comment
I created a few e2e sanity tests for my current project using TestCafe. These tests are standard TestCafe tests:
fixture(`Basic checkout flow`)
test('Main Flow', async (t) =>
);
I would like to execute this test for multiple site locales and for multiple channels. i.e. I need this test to run for nl_nl, nl_be, en_gb, .. and also for channels like b2c, b2b, ...
The easiest way is to create a loop in the test itself to loop over the locales and channels, but I want to run these test concurrently.
I tried to create a function to dynamically generate these tests, but TestCafe cant seem to detect the tests then.
dynamicTest('Main Flow', async (t) =>
);
function dynamicTest(testName, testFn) =>
const channels = ['b2c']
channels.forEach((channel) =>
test(`[Channel] $channel] $testName`, testFn);
);
;
Is there a better way for doing this? The only solution I see is running the test script multiple times from jenkins to have concurrency.
more detailed code:
import HomePage from '../../page/HomePage/HomePage';
import EnvUtil from '../../util/EnvUtil';
const wrapper = (config, testFn) =>
config.locales.forEach(async locale =>
config.channels.forEach(async channel =>
const tstConfig =
locale,
channel
;
tstConfig.env = EnvUtil.parse(tstConfig, config.args.env);
testConfig.foo = await EnvUtil.get() // If I remove this line it works!
testFn(config, locale, channel)
)
);
;
fixture(`[Feature] Feature 1`)
.beforeEach(async t =>
t.ctx.pages =
home: new HomePage(),
... more pages here
;
);
wrapper(global.config, (testConfig, locale, channel) =>
test
.before(async (t) =>
t.ctx.config = testConfig;
)
.page(`foo.bar.com`)
(`[Feature] [Locale: $locale.key] [Channel: $channel.key] Feature 1`, async (t) =>
await t.ctx.pages.home.header.search(t, '3301');
.. more test code here
);
);
If I run it like this I get a "test is undefined" error. Is there something wrong in the way i'm wrapping "test"?
e2e-testing testcafe
1
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
1
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
1
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39
|
show 1 more comment
I created a few e2e sanity tests for my current project using TestCafe. These tests are standard TestCafe tests:
fixture(`Basic checkout flow`)
test('Main Flow', async (t) =>
);
I would like to execute this test for multiple site locales and for multiple channels. i.e. I need this test to run for nl_nl, nl_be, en_gb, .. and also for channels like b2c, b2b, ...
The easiest way is to create a loop in the test itself to loop over the locales and channels, but I want to run these test concurrently.
I tried to create a function to dynamically generate these tests, but TestCafe cant seem to detect the tests then.
dynamicTest('Main Flow', async (t) =>
);
function dynamicTest(testName, testFn) =>
const channels = ['b2c']
channels.forEach((channel) =>
test(`[Channel] $channel] $testName`, testFn);
);
;
Is there a better way for doing this? The only solution I see is running the test script multiple times from jenkins to have concurrency.
more detailed code:
import HomePage from '../../page/HomePage/HomePage';
import EnvUtil from '../../util/EnvUtil';
const wrapper = (config, testFn) =>
config.locales.forEach(async locale =>
config.channels.forEach(async channel =>
const tstConfig =
locale,
channel
;
tstConfig.env = EnvUtil.parse(tstConfig, config.args.env);
testConfig.foo = await EnvUtil.get() // If I remove this line it works!
testFn(config, locale, channel)
)
);
;
fixture(`[Feature] Feature 1`)
.beforeEach(async t =>
t.ctx.pages =
home: new HomePage(),
... more pages here
;
);
wrapper(global.config, (testConfig, locale, channel) =>
test
.before(async (t) =>
t.ctx.config = testConfig;
)
.page(`foo.bar.com`)
(`[Feature] [Locale: $locale.key] [Channel: $channel.key] Feature 1`, async (t) =>
await t.ctx.pages.home.header.search(t, '3301');
.. more test code here
);
);
If I run it like this I get a "test is undefined" error. Is there something wrong in the way i'm wrapping "test"?
e2e-testing testcafe
I created a few e2e sanity tests for my current project using TestCafe. These tests are standard TestCafe tests:
fixture(`Basic checkout flow`)
test('Main Flow', async (t) =>
);
I would like to execute this test for multiple site locales and for multiple channels. i.e. I need this test to run for nl_nl, nl_be, en_gb, .. and also for channels like b2c, b2b, ...
The easiest way is to create a loop in the test itself to loop over the locales and channels, but I want to run these test concurrently.
I tried to create a function to dynamically generate these tests, but TestCafe cant seem to detect the tests then.
dynamicTest('Main Flow', async (t) =>
);
function dynamicTest(testName, testFn) =>
const channels = ['b2c']
channels.forEach((channel) =>
test(`[Channel] $channel] $testName`, testFn);
);
;
Is there a better way for doing this? The only solution I see is running the test script multiple times from jenkins to have concurrency.
more detailed code:
import HomePage from '../../page/HomePage/HomePage';
import EnvUtil from '../../util/EnvUtil';
const wrapper = (config, testFn) =>
config.locales.forEach(async locale =>
config.channels.forEach(async channel =>
const tstConfig =
locale,
channel
;
tstConfig.env = EnvUtil.parse(tstConfig, config.args.env);
testConfig.foo = await EnvUtil.get() // If I remove this line it works!
testFn(config, locale, channel)
)
);
;
fixture(`[Feature] Feature 1`)
.beforeEach(async t =>
t.ctx.pages =
home: new HomePage(),
... more pages here
;
);
wrapper(global.config, (testConfig, locale, channel) =>
test
.before(async (t) =>
t.ctx.config = testConfig;
)
.page(`foo.bar.com`)
(`[Feature] [Locale: $locale.key] [Channel: $channel.key] Feature 1`, async (t) =>
await t.ctx.pages.home.header.search(t, '3301');
.. more test code here
);
);
If I run it like this I get a "test is undefined" error. Is there something wrong in the way i'm wrapping "test"?
e2e-testing testcafe
e2e-testing testcafe
edited Sep 10 '18 at 14:40
Cornel Janssen
asked Sep 7 '18 at 6:39
Cornel JanssenCornel Janssen
258422
258422
1
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
1
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
1
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39
|
show 1 more comment
1
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
1
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
1
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39
1
1
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
1
1
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
1
1
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39
|
show 1 more comment
1 Answer
1
active
oldest
votes
Using TestCafe of version 0.23.1, you can run tests imported from external libraries or generated dynamically even if the test file you provide does not contain any tests.
You can learn more here: Run Dynamically Loaded Tests
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52216685%2ftestcafe-dynamic-tests-cases%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using TestCafe of version 0.23.1, you can run tests imported from external libraries or generated dynamically even if the test file you provide does not contain any tests.
You can learn more here: Run Dynamically Loaded Tests
add a comment |
Using TestCafe of version 0.23.1, you can run tests imported from external libraries or generated dynamically even if the test file you provide does not contain any tests.
You can learn more here: Run Dynamically Loaded Tests
add a comment |
Using TestCafe of version 0.23.1, you can run tests imported from external libraries or generated dynamically even if the test file you provide does not contain any tests.
You can learn more here: Run Dynamically Loaded Tests
Using TestCafe of version 0.23.1, you can run tests imported from external libraries or generated dynamically even if the test file you provide does not contain any tests.
You can learn more here: Run Dynamically Loaded Tests
answered Nov 15 '18 at 8:06
Alex SkorkinAlex Skorkin
2,35221736
2,35221736
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52216685%2ftestcafe-dynamic-tests-cases%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Would you please let me know the TestCafe version you are using?
– Marion
Sep 7 '18 at 12:49
I'm running the latest version (0.22.0)
– Cornel Janssen
Sep 8 '18 at 16:36
1
This example works properly for me with TetstCafe v0.22: github.com/MarinaRukavitsyna/TestCafe_Dynamic_Test. Would you please check it?
– Marion
Sep 10 '18 at 11:12
I will check it, thanks!
– Cornel Janssen
Sep 10 '18 at 12:04
1
I figured out that the cause is a "await fn()" in the wrapper file. I added it to the example. Not sure why though
– Cornel Janssen
Sep 10 '18 at 14:39