bigbite / wp-cypress

WordPress end to end testing with Cypress.io.
MIT License
86 stars 19 forks source link

How to run seeds in a test? #55

Closed rogervanwile closed 3 years ago

rogervanwile commented 3 years ago

Is your feature request related to a problem? Please describe. I'm using wp-cypress to test a plugin. Some tests requires a valid license key, some not. My idea is to create a seed which I can use for the tests with valid license, where a valid license is stored in the database.

Sadly, I'm not able to get it running. I created a new seed, like the following which is located in the seeds folder.

<?php

use WP_Cypress\Seeder\Seeder;

class ValidLicenseSeeder extends Seeder
{
    public function run()
    {
        update_option('my_plugin_license_key', 'I_AM_A_VALID_LICENSE');
    }
}

But how do I execute this seed in the cypress test? I have not found an example or documentation which shows, how i can run a seed in a test?

Describe the solution you'd like Please update documentation with an example.

Describe alternatives you've considered

Additional context

rogervanwile commented 3 years ago

Sorry, my mistake. It's in the documentary, I just missed it.

It's super easy. Just call

cy.seed('ValidLicenseSeeder');