Dokan dev cycle

From getdokan/dokan · View interactive version

Dokan dev cycle is an AI agent skill from the GitHub repository getdokan/dokan. Run tests, linting, and quality checks for Dokan development. Use when running tests, fixing code style, building assets, or following the development workflow.

How to use this skill

Skill file

Dokan Development Cycle

This skill provides guidance for the Dokan Lite development workflow including building, testing, linting, and CI.

Build Commands

npm run start              # Dev build with watch
npm run start:hot          # Dev with HMR (port 8887)
npm run build              # Production build
npm run makepot            # Generate translation .pot file
npm run release            # Full release build

PHP Linting (PHPCS)

composer phpcs             # Check coding standards
composer phpcbf            # Auto-fix coding standard violations

PHPCS config is in phpcs.xml.dist. It scans includes/ only (excludes assets/, src/, lib/, vendor/, tests/).

CI behavior: GitHub Actions runs PHPCS only on changed files in PRs (not the entire codebase).

JavaScript/CSS Linting

npm run lint:js            # ESLint (via @wordpress/scripts)
npm run lint:css           # Stylelint
npm run format             # Code formatting

PHPUnit Tests

npm run phpunit            # Run tests (requires wp-env running)
npm run phpunit:coverage   # Run with coverage report
npm run test:phpunit       # Start env → run tests → stop env

Environment

npm run env:start          # Start wp-env Docker environment
npm run env:stop           # Stop wp-env

Writing PHP Tests

All tests extend DokanTestCase (tests/php/src/DokanTestCase.php):

namespace WeDevs\Dokan\Test\MyDomain;

use WeDevs\Dokan\Test\DokanTestCase;

class MyServiceTest extends DokanTestCase {
    /**
     * @group dokan-my-domain
     */
    public function test_something() {
        wp_set_current_user( $this->seller_id1 );
        $response = $this->get_request( '/my-resource' );
        $this->assertEquals( 200, $response->get_status() );
    }
}

Available Test Helpers

Pre-created users (from DokanTestCase):

REST request helpers:

Test Factories (tests/php/src/Factories/):

Order helpers:

Custom assertions (tests/php/src/CustomAssertion/):

Unit tests (no DB/REST)

Set $is_unit_test = true to skip REST server and database setup:

class MyUnitTest extends DokanTestCase {
    protected $is_unit_test = true;
    // Uses Brain Monkey for mocking WordPress functions
}

Playwright E2E Tests

Config: tests/pw/playwright.config.ts

# Run from tests/pw/ directory
npx playwright test
npx playwright test --grep @lite          # Only lite tests
npx playwright test --grep @pro           # Only pro tests

Test Tags

Page Object Model

70+ page objects in tests/pw/pages/. Follow the POM pattern:

test('admin can set commission', { tag: ['@lite', '@admin'] }, async () => {
    await admin.navigateToCommissionPage();
    // assertions
});

E2E Utilities (`tests/pw/utils/`)

Development Workflow

  1. Make code changes
  2. Run composer phpcs for PHP changes
  3. Run npm run lint:js for JS/TS changes
  4. Run npm run phpunit for unit tests
  5. Fix any issues (composer phpcbf, manual fixes)
  6. Commit only after all checks pass

CI Pipeline (GitHub Actions)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.