summaryrefslogtreecommitdiff
path: root/test/playwright
diff options
context:
space:
mode:
Diffstat (limited to 'test/playwright')
-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
5 files changed, 32 insertions, 30 deletions
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
+});