Skip to content

Commit 8cb54a6

Browse files
committed
Use ES module type.
1 parent 6ca2047 commit 8cb54a6

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
"name": "@wpsyntex/e2e-test-utils",
33
"version": "0.1.0",
44
"description": "End-to-end test utilities for Polylang projects.",
5+
"type": "module",
6+
"main": "./src/index.js",
7+
"exports": {
8+
".": {
9+
"require": "./src/index.js",
10+
"import": "./src/index.js",
11+
"default": "./src/index.js"
12+
}
13+
},
14+
"module": "./src/index.js",
515
"scripts": {
616
"lint:js": "wp-scripts lint-js"
717
},

src/config/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { defineConfig, devices } from '@playwright/test';
22
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath( import.meta.url );
6+
const __dirname = path.dirname( __filename );
37

48
const STORAGE_STATE_PATH =
59
process.env.STORAGE_STATE_PATH ||
@@ -16,7 +20,7 @@ const STORAGE_STATE_PATH =
1620
export function getPlaywrightConfig( options = {} ) {
1721
return defineConfig( {
1822
testDir: './specs',
19-
globalSetup: require.resolve( '../setup/global.setup.js' ),
23+
globalSetup: path.resolve( __dirname, '../setup/global.setup.js' ),
2024
fullyParallel: false,
2125
forbidOnly: !! process.env.CI,
2226
retries: process.env.CI ? 2 : 0,

src/index.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
import { getAllLanguages, deleteAllLanguages } from './languages/index.js';
2+
import { resetAllSettings, setSetting, getSettings } from './settings/index.js';
3+
import {
4+
getAllTerms,
5+
deleteAllTerms,
6+
getTermBySlug,
7+
} from './taxonomies/index.js';
8+
import { getPlaywrightConfig } from './config/index.js';
9+
import globalSetup from './setup/global.setup.js';
10+
111
export {
2-
getLanguage,
312
getAllLanguages,
4-
createLanguage,
5-
deleteLanguage,
613
deleteAllLanguages,
7-
} from './languages';
8-
export { resetAllSettings, setSetting, getSettings } from './settings';
9-
export { getAllTerms, deleteAllTerms, getTermBySlug } from './taxonomies';
10-
export { getPlaywrightConfig } from './config';
11-
export { default as globalSetup } from './setup/global.setup';
14+
resetAllSettings,
15+
setSetting,
16+
getSettings,
17+
getAllTerms,
18+
deleteAllTerms,
19+
getTermBySlug,
20+
getPlaywrightConfig,
21+
globalSetup,
22+
};

src/setup/global.setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { request } from '@playwright/test';
22
import { RequestUtils } from '@wordpress/e2e-test-utils-playwright';
3-
import { deleteAllLanguages, resetAllSettings } from '..';
3+
import { deleteAllLanguages } from '../languages/index.js';
4+
import { resetAllSettings } from '../settings/index.js';
45

56
/**
67
* Partially copied from Gutenberg and converted from Typescript.

0 commit comments

Comments
 (0)