Reusing test code and test files organization in Testcafe



  • I'm having a hard time figuring out how to organize my test code, i.e. test cases, into suites and runs.

    On the one hand, tests should, by definition, be independent of each other, that's why I, for example, have a test file for only doing the login operation and another one for doing something on the welcome page.

    Thing is, in order to get to the welcome page, you must first login.
    Makes sense.

    In other test frameworks I've used in the past I knew how to call one test case from another (i.e. reusing code from one file in the other file).

    However, my current company uses Testcafe as our automation tool, and try as I might to find an answer online, I can't see how I can use the login code (say it's in file loginTest.js) in the welcome page code (in welcomePageTest.js).

    If at all possible I'd like to stay away from solutions such as creating a runner script and running it as I like working in Live mode.

    Any ideas on how to reuse and call tests from one file in another in Testcafe?



  • It's an easy solution, you just need to import all the js functions, create an object of those functions and use it in your test fixtures

    Astaqc.com: outsource Software Testing



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2