|
| 1 | +# CodeceptJS Testing Cheat Sheet |
| 2 | + |
| 3 | +## Testing Libraries and Frameworks |
| 4 | +- Jest |
| 5 | +- Chai |
| 6 | +- Sinon |
| 7 | +- Mocha |
| 8 | + |
| 9 | +## Mocking and Stubbing |
| 10 | +- Sinon is used for mocking and stubbing |
| 11 | +- `sinon.spy()` for creating spies |
| 12 | +- `sinon.mock()` for creating mocks |
| 13 | +- `sinon.stub()` for creating stubs |
| 14 | + |
| 15 | +## Assertions |
| 16 | +- Chai assertions are used (`expect` syntax) |
| 17 | +- Jest assertions are also used in some tests |
| 18 | + |
| 19 | +## Test Structure |
| 20 | +- `describe()` for grouping tests |
| 21 | +- `it()` for individual test cases |
| 22 | +- `before()`, `beforeEach()`, `after()`, `afterEach()` for setup and teardown |
| 23 | + |
| 24 | +## CodeceptJS Specific |
| 25 | +- `Feature()` for defining features |
| 26 | +- `Scenario()` for defining scenarios |
| 27 | +- `Given()`, `When()`, `Then()` for BDD-style steps |
| 28 | +- `I` object for actor actions |
| 29 | + |
| 30 | +## Helpers and Plugins |
| 31 | +- Custom helpers can be created and used |
| 32 | +- Plugins like `tryTo` and `subtitles` are available |
| 33 | + |
| 34 | +## Configuration |
| 35 | +- `codecept.conf.js` for main configuration |
| 36 | +- Config can be manipulated programmatically using `config` module |
| 37 | + |
| 38 | +## Events |
| 39 | +- `event` module for handling test events |
| 40 | +- Custom event listeners can be added |
| 41 | + |
| 42 | +## Recorder |
| 43 | +- `recorder` module for managing test execution flow |
| 44 | + |
| 45 | +## Locators |
| 46 | +- Custom locator strategies can be defined |
| 47 | +- XPath and CSS selectors are supported |
| 48 | + |
| 49 | +## Data Tables |
| 50 | +- Gherkin-style data tables are supported in scenarios |
| 51 | + |
| 52 | +## Retries |
| 53 | +- `I.retry()` for retrying failed steps |
| 54 | + |
| 55 | +## AI Assistant |
| 56 | +- `AiAssistant` module for AI-powered testing assistance |
| 57 | + |
| 58 | +## File Operations |
| 59 | +- `fs` and `path` modules are used for file operations |
| 60 | + |
| 61 | +## HTML Processing |
| 62 | +- Functions for minifying and processing HTML for tests |
| 63 | + |
| 64 | +## Artifacts |
| 65 | +- Video recording and subtitle generation for failed tests |
| 66 | + |
| 67 | +This cheat sheet covers the main testing practices and tools used in the CodeceptJS codebase. It includes information on testing frameworks, mocking, assertions, test structure, CodeceptJS-specific features, and various utilities and modules used throughout the tests. |
0 commit comments