Testcafe: Expose fixture and test functions to allow to use them dynamically

Created on 4 Apr 2017  路  40Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Requesting a feature

What is the current behavior?

For TestCafe to run a test we have to create a file which explicitly calls the fixture() and the test() function at least once.

What is the expected behavior?

Ideally we should be able to grab a handle of this functions without requiring to create a test file, this would allow us to integrate TestCafe with other test tools. I'm currently struggling to integrate with CucumberJS. Being able to have a reference to the fixture() and test() global functions would allow me to use the CucumberJS hooks which would help in transitioning to TestCafe without losing a lot of feature files that have been written with the Gherkin syntax.

How would you reproduce the current behavior (if this is a bug)?

N/A

Is there any others wishing to integrate TestCafe with other test tools? I'm currently working on a hacky solutions which involves generating test files at test execution time, requiring my actual test files and passing the fixture and test functions as reference (still not working thought). And I would like to know if there's any blessed way of doing this cleanly in a supported way.

API compiler enhancement

Most helpful comment

But on the other hand I guess the better way to solve this will be plugable compilers. You will create testcafe-compiler-cucumber plugin which will be automatically loaded by TestCafe if installed. Plugin will decide which files to compile (by file extension and content patterns) and will implement logic that converts file content into sequence of test and fixture calls. Actually, we almost have this mechanism implemented (TestCafe currently supports 3 different types of test syntax, but it's a big secret ;)), therefore we just need to make its API public.

All 40 comments

Can you give some example of how you expect it to work, please? E.g. if we expose these functions, how test task should be started? Currently you tell TestCafe to run specific file/dir and it lookups for file with test() calls and execute them. How workflow will look like with exposed functions?

Of course this is just an idea, but I'm thinking of something like the following:

createTestCafe('localhost').then(testcafe => {
  const runner = testcafe
    .createRunner()
    .browsers(['chrome']);

  const { fixture, test } = runner.getHandlers();

  myOtherTestFramework.getFeatures().forEach(feature => {
    fixture(feature.name);
    feature.steps.forEach(step => {
      test(step.name, step.fn);
    });
  })

  runner.run();
});

@reaktivo How about

runner.populateTests('suite/file name', (fixture, test) => {
    fixture(feature.name);

    feature.steps.forEach(step => {
      test(step.name, step.fn);
    });
});

?

But on the other hand I guess the better way to solve this will be plugable compilers. You will create testcafe-compiler-cucumber plugin which will be automatically loaded by TestCafe if installed. Plugin will decide which files to compile (by file extension and content patterns) and will implement logic that converts file content into sequence of test and fixture calls. Actually, we almost have this mechanism implemented (TestCafe currently supports 3 different types of test syntax, but it's a big secret ;)), therefore we just need to make its API public.

@inikulin What is the progress on this? I would love to use testcafe with BDD :)

are there any news on this? :)

Waiting for some native BDD support as well.

I am also interested in this integration. I've tried my best to integrate Cucumber and TestCafe, but my solution loses some of the features of TestCafe in the process. If there could be an easier way it would be appreciated.

Yes I'm very interested in this too...I tried to integrate cucumberjs & testcafe but have found it to be seriously challenging at times :(

I am also interested in this integration...

Is there a way that we can control the lifecycle of test controller, so that we can use testcafe more like a library than a framework? Just like web driver does.

I tried integrating with Gauge but it looks like there's a problem with the Gauge library. Having the ability to integrate with BDD would be finding the lost ark of agile testing :)

I agree with everybody else. It would be best if we can get this soon because the workaround looses features in testcafe.

any update on this ? team is very keen in using BDD with testcafe. It will be biggest milestone for people migrating from web-driver to testcafe and not going for cypress

Hey I'd love to have official support too.

In the meantime I have created an unoffical integration with cucumberjs and TestCafe. Some folks here may find it useful. Link below

https://github.com/bhreinb/SYSTAC

Please update once we have stable cucumber bdd integration with testcafe. Currently, i am also facing issues with fixture and test using cucumber bdd.

we've been using rquellh's testcafe-cucumber repo and love it. it's helped us write more reusable and understandable tests. we also reuse the feature tests for cross-browser testing.

https://github.com/rquellh/testcafe-cucumber/blob/master/README.md

would love to see official support for cucumber-js in testcafe (so that we can upgrade, share knowledge with the larger community etc.)

Hi Kenf128 , I am also using the same bdd https://github.com/rquellh/testcafe-cucumber/blob/master/README.md but my problem is how can i use the requestHooks for logger and custom hooks in this framework. How to attach to tests. If anyone has similar issue and solution please share.

Hi @inikulin!

When cucumber will be officially supported? I'm dying for it..

+1

+1, any news on this?

+1, any news on this?

I've already checked some integrations made by the community but they don't support all the features offered by TestCafe. I would be glad if there was more support for BDD :+1:

Just to point at a another community solution out there, that I find pretty useful (though I couldn't tell whether it's complete in the sense @ampc mentioned above):
https://github.com/kiwigrid/gherkin-testcafe

The README of that package also refers to this issue, pointing out that it is going to be abandoned, once an official solution has been established.

Maybe someone will find it to be a viable temporary solution :)

grebaldi That solution has no posibility to create reports showing every step, it only reports the name of the test that passed/failed. Or you would have to build something yourself of course.

https://github.com/kiwigrid/gherkin-testcafe/issues/7

+1!

+1, Any updates for BDD native support?

@shane51
We have plans to implement BDD support in the future. We added this feature in our roadmap either. But at this moment we are not ready to give any estimates on this.

UPDATED
I mean that we are planning to implement integration with Cucumber in one way or another.

+1
Any update on this? would love to use Testcafe with BDD

@yrnayudu

Hello,

No updates, yet. We still can't give you any estimate on this.

+1

+100

Any further update on this?

Once we get any results, we will post them here.

this is the main reason our company isn't using testcafe for now.

I also would like to use Gherkin with TestCafe

Are there any updates for this feature?

Once we get any results, we will post them here.

Hi TestCafe team,
This is such a wonderful tool but lack of official integration with Gherkin put this tool behind others during tools evaluation. I am using this tool since 2018 and am looking forward to providing a more robust framework to my clients. Any timeframe marked in your roadmap for this release?

Hello @vvedachalam
At this moment this functionality is not in our Roadmap, so we cannot give you any precise information on your issue.
It was discussed in https://github.com/DevExpress/testcafe/issues/4682
You can try to use the gherkin-testcafe module mentioned in #4682

Was this page helpful?
0 / 5 - 0 ratings

Related issues

madroneropaulo picture madroneropaulo  路  3Comments

multivoltage picture multivoltage  路  3Comments

devmondo picture devmondo  路  3Comments

inikulin picture inikulin  路  3Comments

fnlctrl picture fnlctrl  路  3Comments