aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--playwright.config.js4
-rw-r--r--test/playwright/global.setup.js12
-rw-r--r--test/playwright/global.teardown.js10
-rw-r--r--test/playwright/integration.spec.js18
-rw-r--r--test/playwright/playwright-util.js10
-rw-r--r--test/playwright/visual.spec.js12
6 files changed, 34 insertions, 32 deletions
diff --git a/playwright.config.js b/playwright.config.js
index 11d79e72..acb3e1af 100644
--- a/playwright.config.js
+++ b/playwright.config.js
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// @ts-check
-const {defineConfig, devices} = require('@playwright/test');
+import {defineConfig, devices} from '@playwright/test';
/**
* Read environment variables from file.
@@ -26,7 +26,7 @@ const {defineConfig, devices} = require('@playwright/test');
/**
* @see https://playwright.dev/docs/test-configuration
*/
-module.exports = defineConfig({
+export default defineConfig({
testDir: './test/playwright',
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
/* Maximum time one test can run for. */
diff --git a/test/playwright/global.setup.js b/test/playwright/global.setup.js
index 442647f8..1a16f120 100644
--- a/test/playwright/global.setup.js
+++ b/test/playwright/global.setup.js
@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const {test: setup} = require('@playwright/test');
-const {ManifestUtil} = require('../../dev/manifest-util');
-const {root} = require('./playwright-util');
-const path = require('path');
-const fs = require('fs');
+import {test as setup} from '@playwright/test';
+import fs from 'fs';
+import path from 'path';
+import {ManifestUtil} from '../../dev/manifest-util';
+import {root} from './playwright-util';
const manifestPath = path.join(root, 'ext/manifest.json');
const copyManifestPath = path.join(root, 'ext/manifest-old.json');
@@ -29,4 +29,4 @@ setup('use test manifest', () => {
const variant = manifestUtil.getManifest('chrome-playwright');
fs.renameSync(manifestPath, copyManifestPath);
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(variant).replace('$YOMITAN_VERSION', '0.0.0.0'));
-}); \ No newline at end of file
+});
diff --git a/test/playwright/global.teardown.js b/test/playwright/global.teardown.js
index 2fb29ebe..6787f255 100644
--- a/test/playwright/global.teardown.js
+++ b/test/playwright/global.teardown.js
@@ -15,14 +15,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const {test: teardown} = require('@playwright/test');
-const {root} = require('./playwright-util');
-const path = require('path');
-const fs = require('fs');
+import {test as teardown} from '@playwright/test';
+import fs from 'fs';
+import path from 'path';
+import {root} from './playwright-util';
const manifestPath = path.join(root, 'ext/manifest.json');
const copyManifestPath = path.join(root, 'ext/manifest-old.json');
teardown('bring back original manifest', () => {
fs.renameSync(copyManifestPath, manifestPath);
-}); \ No newline at end of file
+});
diff --git a/test/playwright/integration.spec.js b/test/playwright/integration.spec.js
index 1bfd39ea..b9a86d84 100644
--- a/test/playwright/integration.spec.js
+++ b/test/playwright/integration.spec.js
@@ -15,18 +15,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const path = require('path');
-const {
- test,
+import path from 'path';
+import {createDictionaryArchive} from '../../dev/util';
+import {
expect,
- root,
- mockModelFieldNames,
- mockModelFieldsToAnkiValues,
expectedAddNoteBody,
mockAnkiRouteHandler,
+ mockModelFieldNames,
+ mockModelFieldsToAnkiValues,
+ root,
+ test,
writeToClipboardFromPage
-} = require('./playwright-util');
-const {createDictionaryArchive} = require('../../dev/util');
+} from './playwright-util';
test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
@@ -91,4 +91,4 @@ test('anki add', async ({context, page, extensionId}) => {
await page.locator('[data-mode="term-kanji"]').click();
const addNoteReqBody = await addNotePromise;
expect(addNoteReqBody).toMatchObject(expectedAddNoteBody);
-}); \ No newline at end of file
+});
diff --git a/test/playwright/playwright-util.js b/test/playwright/playwright-util.js
index e28f16eb..5ceb92fd 100644
--- a/test/playwright/playwright-util.js
+++ b/test/playwright/playwright-util.js
@@ -15,10 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const path = require('path');
-const {test: base, chromium} = require('@playwright/test');
+import {test as base, chromium} from '@playwright/test';
+import path from 'path';
+import {fileURLToPath} from 'url';
-export const root = path.join(__dirname, '..', '..');
+const dirname = path.dirname(fileURLToPath(import.meta.url));
+export const root = path.join(dirname, '..', '..');
export const test = base.extend({
context: async ({ }, use) => {
@@ -106,4 +108,4 @@ const ankiRouteResponses = {
'canAddNotes': Object.assign({body: JSON.stringify([true, true])}, baseAnkiResp),
'storeMediaFile': Object.assign({body: JSON.stringify('mock_audio.mp3')}, baseAnkiResp),
'addNote': Object.assign({body: JSON.stringify(102312488912)}, baseAnkiResp)
-}; \ No newline at end of file
+};
diff --git a/test/playwright/visual.spec.js b/test/playwright/visual.spec.js
index 001f329f..2f46990f 100644
--- a/test/playwright/visual.spec.js
+++ b/test/playwright/visual.spec.js
@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-const path = require('path');
+import path from 'path';
-const {
- test,
+import {
expect,
- root
-} = require('./playwright-util');
+ root,
+ test
+} from './playwright-util';
test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
@@ -97,4 +97,4 @@ test('visual', async ({page, extensionId}) => {
await screenshot(2, i, el, {x: 15, y: 15});
i++;
}
-}); \ No newline at end of file
+});