THIS IS DRAFT AND NEEDS TO BE REVISED
The following bullet points provide some helpful tips for testing entry points:
- Tests can output messages to the console using the
cy.taskcommand.- Use
cy.task('log', 'message')to log text messages. - Use:
cy.task('logObject', obj)to log an object to the console.
- Use
Best practice is to reset the database state before tests are run. Doing this before every test or even at the start of every file adds significantly to the runtime of the test suite. FarmData2 compromises by resetting the database to the DB that was most recently installed (i.e. using installDB.bash) before each test run. A test run is one cypress command (e.g. as is done by test.bash --comp). Any test that absolutely requires a clean database (i.e. cannot tolerate changes made by prior tests) can reset it in its before hook using the following code:
before(() => {
cy.task('initDB');
});You can change the database that will be used for testing by using the installDB.bash script manually prior to running the tests. This is useful when you want to run tests against a pre-release of the sample database. For example:
installDB.bash --release=v3.1.0-development.3 --asset=db.sample.tar.gz-
Any
itwith aninterceptshould include{ retries: 4 }to tolerate some of the flake that appears to go withcy.intercept. -
clear()fields with content beforetype()ing in them -
blur()any field that wastype()d in orclear()ed before doing a submit or relying on its value. If changing lots of fields, then only need toblurthe last one. -
When setting or checking the value of a selector or numeric input be sure to get the element from the sub-component (e.g.
selector-inputornumeric-input). Some methods work on the parent component, but others do not. So, it is always safest to work with the*-inputelement itself. -
If a contained
data-cyis unique to a page just use it.cy.getting the parent element and usingfindmay not work. Very strange behavior. -
To use
select()on a component built on top of theSelectorBasecomponent, you must usecy.get(<component>).find('selector-input').select(<item>)
Note: Every test it should wait for the ready event to be emitted before performing any tests. In some components this will be immediately, in others it will wait for an API call to complete. This is included in all tests for consistency and to reduce test flake.
Use: cy.task('log', 'message') to log messages to the console.
Use: cy.task('logObject', obj) to log an object to the console.
- Visible in the console when running headless.
- Click on the task in the test events output to print to console in Cypress gui.