@stratawp/testing 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +579 -0
- package/dist/index.d.ts +227 -0
- package/dist/index.js +308 -0
- package/dist/index.js.map +1 -0
- package/dist/playwright.d.ts +98 -0
- package/dist/playwright.js +143 -0
- package/dist/playwright.js.map +1 -0
- package/dist/vitest.d.ts +4 -0
- package/dist/vitest.js +322 -0
- package/dist/vitest.js.map +1 -0
- package/package.json +70 -0
- package/playwright.config.ts +84 -0
- package/vitest.config.ts +43 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Playwright E2E Test Configuration
|
|
5
|
+
* See https://playwright.dev/docs/test-configuration
|
|
6
|
+
*/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
testDir: './e2e',
|
|
9
|
+
|
|
10
|
+
/* Maximum time one test can run for */
|
|
11
|
+
timeout: 30 * 1000,
|
|
12
|
+
|
|
13
|
+
/* Run tests in files in parallel */
|
|
14
|
+
fullyParallel: true,
|
|
15
|
+
|
|
16
|
+
/* Fail the build on CI if you accidentally left test.only */
|
|
17
|
+
forbidOnly: !!process.env.CI,
|
|
18
|
+
|
|
19
|
+
/* Retry on CI only */
|
|
20
|
+
retries: process.env.CI ? 2 : 0,
|
|
21
|
+
|
|
22
|
+
/* Opt out of parallel tests on CI */
|
|
23
|
+
workers: process.env.CI ? 1 : undefined,
|
|
24
|
+
|
|
25
|
+
/* Reporter to use */
|
|
26
|
+
reporter: [
|
|
27
|
+
['html'],
|
|
28
|
+
['json', { outputFile: 'test-results/results.json' }],
|
|
29
|
+
['junit', { outputFile: 'test-results/junit.xml' }],
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
/* Shared settings for all the projects below */
|
|
33
|
+
use: {
|
|
34
|
+
/* Base URL for WordPress */
|
|
35
|
+
baseURL: process.env.WP_BASE_URL || 'http://localhost:8888',
|
|
36
|
+
|
|
37
|
+
/* Collect trace when retrying the failed test */
|
|
38
|
+
trace: 'on-first-retry',
|
|
39
|
+
|
|
40
|
+
/* Screenshot on failure */
|
|
41
|
+
screenshot: 'only-on-failure',
|
|
42
|
+
|
|
43
|
+
/* Video on failure */
|
|
44
|
+
video: 'retain-on-failure',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/* Configure projects for major browsers */
|
|
48
|
+
projects: [
|
|
49
|
+
{
|
|
50
|
+
name: 'chromium',
|
|
51
|
+
use: { ...devices['Desktop Chrome'] },
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
name: 'firefox',
|
|
56
|
+
use: { ...devices['Desktop Firefox'] },
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
name: 'webkit',
|
|
61
|
+
use: { ...devices['Desktop Safari'] },
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/* Test against mobile viewports */
|
|
65
|
+
{
|
|
66
|
+
name: 'Mobile Chrome',
|
|
67
|
+
use: { ...devices['Pixel 5'] },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Mobile Safari',
|
|
71
|
+
use: { ...devices['iPhone 12'] },
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
|
|
75
|
+
/* Run your local dev server before starting the tests */
|
|
76
|
+
webServer: process.env.CI
|
|
77
|
+
? undefined
|
|
78
|
+
: {
|
|
79
|
+
command: 'npm run dev',
|
|
80
|
+
url: 'http://localhost:3000',
|
|
81
|
+
reuseExistingServer: !process.env.CI,
|
|
82
|
+
timeout: 120 * 1000,
|
|
83
|
+
},
|
|
84
|
+
})
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
test: {
|
|
8
|
+
globals: true,
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
setupFiles: ['./src/setup.ts'],
|
|
11
|
+
coverage: {
|
|
12
|
+
provider: 'v8',
|
|
13
|
+
reporter: ['text', 'json', 'html', 'lcov'],
|
|
14
|
+
exclude: [
|
|
15
|
+
'node_modules/',
|
|
16
|
+
'dist/',
|
|
17
|
+
'**/*.test.{ts,tsx}',
|
|
18
|
+
'**/*.spec.{ts,tsx}',
|
|
19
|
+
'**/mocks/**',
|
|
20
|
+
'**/*.config.{ts,js}',
|
|
21
|
+
],
|
|
22
|
+
thresholds: {
|
|
23
|
+
lines: 80,
|
|
24
|
+
functions: 80,
|
|
25
|
+
branches: 75,
|
|
26
|
+
statements: 80,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
include: ['**/*.{test,spec}.{ts,tsx}'],
|
|
30
|
+
exclude: ['node_modules', 'dist', 'build'],
|
|
31
|
+
},
|
|
32
|
+
resolve: {
|
|
33
|
+
alias: {
|
|
34
|
+
'@': path.resolve(__dirname, './src'),
|
|
35
|
+
'@wordpress/blocks': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
36
|
+
'@wordpress/data': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
37
|
+
'@wordpress/i18n': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
38
|
+
'@wordpress/components': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
39
|
+
'@wordpress/block-editor': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
40
|
+
'@wordpress/element': path.resolve(__dirname, './src/mocks/wordpress.ts'),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
})
|