You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a lint rule that warns about using direct actions from being used in a test
Problem
Brittle test cases when simple features on the UI change. It causes tests to need to be re-written and evaluated which is against the concept of test like a user would.
So the goal is to have tests that are flexible enough to focus on only the features that are provided and not be tightly coupled to how the interface is constructed. The page model abstraction recommended by TestCafe demonstrates how to build tests that maintain their integrity but handle interaction changes. Hopefully, eslint can provide incentive and enforcement in implementing the page model construct amongst all test cases.
Expected behavior
// page.test.js - invalid example// Derived from https://testcafe.io/documentation/402826/guides/concepts/page-modeltest('Text typing basics',asynct=>{awaitt.typeText('#developer-name','Peter').click("#submit").expect(Selector('#developer-name').value).eql('Parker');});
# Run Lint
eslint ./tests/page.test.js
Should return an warning on line 5 & 6, highlighting the typeText(...) & click(...). Recommend abstracting away actions into readable action methods on a page and calling the actions with parameters.
Ideal page model with abstracted action methods should look like this:
// page.test.js - desired implementationimport{t}from"testcafe"import{page}from"./models"test('Submit a developer name and check the header',asynct=>{awaitpage.submitName('Peter');awaitt.expect(page.header.userName.innerText).eql('Thank you, Peter!');});
The text was updated successfully, but these errors were encountered:
Feature Request
Add a lint rule that warns about using direct actions from being used in a test
Problem
Brittle test cases when simple features on the UI change. It causes tests to need to be re-written and evaluated which is against the concept of test like a user would.
So the goal is to have tests that are flexible enough to focus on only the features that are provided and not be tightly coupled to how the interface is constructed. The page model abstraction recommended by TestCafe demonstrates how to build tests that maintain their integrity but handle interaction changes. Hopefully, eslint can provide incentive and enforcement in implementing the page model construct amongst all test cases.
Expected behavior
# Run Lint eslint ./tests/page.test.js
Should return an warning on line 5 & 6, highlighting the
typeText(...)
&click(...)
. Recommend abstracting away actions into readable action methods on a page and calling the actions with parameters.Ideal page model with abstracted action methods should look like this:
The text was updated successfully, but these errors were encountered: