Test Overview
This test reads the contents of a file named example.txt and verifies that it contains the expected text.
This test reads the contents of a file named example.txt and verifies that it contains the expected text.
describe('Reading file contents', () => { it('should read the file and verify its content', () => { cy.readFile('cypress/fixtures/example.txt').then((content) => { expect(content).to.contain('Hello, Cypress!'); }); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner is initialized | - | PASS |
| 2 | Cypress reads the file 'cypress/fixtures/example.txt' using cy.readFile | File system accessed, file content loaded into memory | - | PASS |
| 3 | Test code executes the callback with file content | File content is available as a string | Check if file content contains 'Hello, Cypress!' | PASS |
| 4 | Assertion passes confirming file content is as expected | Test runner shows test passed | expect(content).to.contain('Hello, Cypress!') | PASS |