The default Wordless theme is shipped with preconfigured test suite.
By default Wordless is configured to run acceptance (aka integration or e2e or browser) test suite alone. If you’d like to run functional or unit suites, you’ll simply have to update the
yarn test script accordingly in
Add tests to the
tests/acceptance/WPFirstCest.php file or write your own file in the same folder.
To run acceptance test suite you have to start the test server in one terminal
and in another terminal let’s actually run tests:
test will simply run acceptance test suite,
test:server is a variant of the default
server task which load different
Where are test configurations?¶
test/folder. This is where your test suites lay.
- PHP dependencies declared in
composer.jsonfile shipped within the theme. This will create a
/vendorfolder inside the theme whilist
wp-config.php. This will be helpful to autodymagically (automatically, dynamically, magically; just in case you were wondering 🙄) switch from development to test database whilist test suite execution
- 2 test related node scripts:
yarn test. Obviously declared inside
- a test database on your local machine called
$THEME_NAMEis the chosen name during Wordless’ installation process) is created whilist
- ad hoc
.gitlab-ci.ymlfile into the project root
vendor/ folders are ignored in
.gitignore by default
How should I write tests?¶
This documentation is not intended to giude you thourgh testing concepts nor on Codeception’s syntax. You can already find great documentation and I advice you to start from
where you will find Wordpress specific methods and links to base Codeception’s methods all in one place.
We ship default configuration for GitLab by putting a
.gitlab-ci.yml file in you project’s root folder.
That is configured to run out-of-the-box. And if you use other CI’s products you can use it as a starting point for your own configuration and then delete it without any regard :)
yarn setup -> Error: Error establishing a database connection.
Check your db’s username & password in the
yarn test -> Db: SQLSTATE[HY000]  The server requested authentication method unknown to the client while creating PDO connection
Check your db’s username & password in
.env.testing, inside the theme’s folder
yarn test -> Could not find, or could not parse, the original site URL; you can set the “originalUrl” parameter in the module configuration to skip this step and fix this error.
yarn test:db:snapshotcan be useful.
yarn test -> [ConnectionException] Can’t connect to Webdriver at http://localhost:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.
Check if you are running
yarn test:serverin another terminal ☺️.