mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
test: remove hacky requires, use imports instead (#4835)
Since our client implements our types, we can now import implementation in tests without type conflicts.
This commit is contained in:
parent
94077e0e74
commit
4c11f5d885
@ -15,10 +15,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import * as path from 'path';
|
||||
|
||||
const { parseCSS, serializeSelector: serialize } =
|
||||
require(path.join(__dirname, '..', 'lib', 'server', 'common', 'cssParser'));
|
||||
import { parseCSS, serializeSelector as serialize } from '../src/server/common/cssParser';
|
||||
|
||||
const parse = (selector: string) => {
|
||||
return parseCSS(selector, new Set(['text', 'not', 'has', 'react', 'scope', 'right-of', 'scope', 'is'])).selector;
|
||||
|
@ -18,6 +18,7 @@
|
||||
import { folio, RemoteServer } from './remoteServer.fixture';
|
||||
import { execSync } from 'child_process';
|
||||
import path from 'path';
|
||||
import * as stackTrace from '../src/utils/stackTrace';
|
||||
|
||||
type FixturesFixtures = {
|
||||
connectedRemoteServer: RemoteServer;
|
||||
@ -129,7 +130,6 @@ describe('fixtures', (suite, { platform, headful }) => {
|
||||
});
|
||||
|
||||
it('caller file path', async ({}) => {
|
||||
const stackTrace = require(path.join(__dirname, '..', 'lib', 'utils', 'stackTrace'));
|
||||
const callme = require('./fixtures/callback');
|
||||
const filePath = callme(() => {
|
||||
return stackTrace.getCallerFilePath(path.join(__dirname, 'fixtures') + path.sep);
|
||||
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import * as path from 'path';
|
||||
|
||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
||||
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||
|
||||
it('should throw for non-string selector', async ({page}) => {
|
||||
const error = await page.$(null).catch(e => e);
|
||||
|
@ -15,10 +15,8 @@
|
||||
*/
|
||||
|
||||
import { folio } from './fixtures';
|
||||
import * as path from 'path';
|
||||
import type { Page, Frame } from '..';
|
||||
|
||||
const { source } = require(path.join(__dirname, '..', 'lib', 'generated', 'consoleApiSource'));
|
||||
import { source } from '../src/generated/consoleApiSource';
|
||||
|
||||
const fixtures = folio.extend();
|
||||
fixtures.context.override(async ({ context }, run) => {
|
||||
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import * as path from 'path';
|
||||
|
||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
||||
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||
|
||||
it('should work with large DOM', async ({page, server}) => {
|
||||
await page.evaluate(() => {
|
||||
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import * as path from 'path';
|
||||
|
||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
||||
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||
|
||||
it('should work for open shadow roots', async ({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/deep-shadow.html');
|
||||
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
|
||||
import { it, expect } from './fixtures';
|
||||
import * as path from 'path';
|
||||
|
||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
||||
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||
|
||||
it('should work', async ({page}) => {
|
||||
await page.setContent(`<div>yo</div><div>ya</div><div>\nye </div>`);
|
||||
|
Loading…
Reference in New Issue
Block a user