Skip to content

Instantly share code, notes, and snippets.

View dream-encode's full-sized avatar
🎄

David B dream-encode

🎄
View GitHub Profile
@dream-encode
dream-encode / blog-entry-end-to-end-tests-for-wordpress-plugins-package-json
Created January 18, 2023 22:06
WordPress Plugin E2E Testing with Playwright - package.json
"scripts": {
"dev": "webpack --watch --mode development",
"test:e2e": "npm run production && npx playwright test",
"production": "webpack --mode production"
},
@dream-encode
dream-encode / blog-entry-end-to-end-tests-for-wordpress-plugins-login-test
Created January 18, 2023 21:55
WordPress Plugin E2E Testing with Playwright - Login Test
import { test, expect } from '@playwright/test'
test( 'site works', async ( { page } ) => {
await page.goto( '/wp-login.php' )
const heading = page.getByRole( 'heading', { name: 'Powered by WordPress' } )
await expect( heading ).toBeVisible()
} )
@dream-encode
dream-encode / blog-entry-end-to-end-tests-for-wordpress-plugins-global-setup
Created January 18, 2023 21:54
WordPress Plugin E2E Testing with Playwright - Global Setup
import { chromium } from '@playwright/test'
async function globalSetup( config ) {
const { baseURL } = config.projects[0].use
const browser = await chromium.launch()
const page = await browser.newPage()
try {
@dream-encode
dream-encode / blog-entry-end-to-end-tests-for-wordpress-plugins-playwright-config
Created January 18, 2023 21:52
WordPress Plugin E2E Testing with Playwright - Playwright Config
const config = {
globalSetup: require.resolve( './tests/e2e/globalSetup.js' ),
testDir: 'tests/e2e',
testMatch: '**/*.js',
use: {
baseURL: 'http://localhost:8080', // UPDATE THIS WITH YOUR LOCAL ENVIRONMENT URL.
screenshot: 'only-on-failure',
timeout: 60000,
}
}
@dream-encode
dream-encode / globalSetup.js
Created January 18, 2023 21:50
WordPress Plugin E2E Testing with Playwright - Global Setup
import { chromium } from '@playwright/test'
async function globalSetup( config ) {
    const { baseURL } = config.projects[0].use
    const browser = await chromium.launch()
    const page = await browser.newPage()
    try {
@dream-encode
dream-encode / gist:bdf7e84441c7173e24cbccbdf79291ce
Created September 19, 2017 16:38 — forked from dustyf/gist:b6e72a7a7fd05de9598e
Example WordPress Simple JSON Endpoint Plugin
<?php
/**
* Plugin Name: WDS GIF API
* Plugin URI: http://webdevstudios.com
* Description: Adds a Custom Post Type to store GIFs and an API JSON Endpoint to access GIFs by a tag.
* Author: WebDevStudios
* Author URI: http://webdevstudios.com
* Version: 1.0.0
* License: GPLv2
*/