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 { it, expect } from './fixtures';
|
||||||
import * as path from 'path';
|
import { parseCSS, serializeSelector as serialize } from '../src/server/common/cssParser';
|
||||||
|
|
||||||
const { parseCSS, serializeSelector: serialize } =
|
|
||||||
require(path.join(__dirname, '..', 'lib', 'server', 'common', 'cssParser'));
|
|
||||||
|
|
||||||
const parse = (selector: string) => {
|
const parse = (selector: string) => {
|
||||||
return parseCSS(selector, new Set(['text', 'not', 'has', 'react', 'scope', 'right-of', 'scope', 'is'])).selector;
|
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 { folio, RemoteServer } from './remoteServer.fixture';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import * as stackTrace from '../src/utils/stackTrace';
|
||||||
|
|
||||||
type FixturesFixtures = {
|
type FixturesFixtures = {
|
||||||
connectedRemoteServer: RemoteServer;
|
connectedRemoteServer: RemoteServer;
|
||||||
|
|
@ -129,7 +130,6 @@ describe('fixtures', (suite, { platform, headful }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('caller file path', async ({}) => {
|
it('caller file path', async ({}) => {
|
||||||
const stackTrace = require(path.join(__dirname, '..', 'lib', 'utils', 'stackTrace'));
|
|
||||||
const callme = require('./fixtures/callback');
|
const callme = require('./fixtures/callback');
|
||||||
const filePath = callme(() => {
|
const filePath = callme(() => {
|
||||||
return stackTrace.getCallerFilePath(path.join(__dirname, 'fixtures') + path.sep);
|
return stackTrace.getCallerFilePath(path.join(__dirname, 'fixtures') + path.sep);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, expect } from './fixtures';
|
import { it, expect } from './fixtures';
|
||||||
import * as path from 'path';
|
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||||
|
|
||||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
|
||||||
|
|
||||||
it('should throw for non-string selector', async ({page}) => {
|
it('should throw for non-string selector', async ({page}) => {
|
||||||
const error = await page.$(null).catch(e => e);
|
const error = await page.$(null).catch(e => e);
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { folio } from './fixtures';
|
import { folio } from './fixtures';
|
||||||
import * as path from 'path';
|
|
||||||
import type { Page, Frame } from '..';
|
import type { Page, Frame } from '..';
|
||||||
|
import { source } from '../src/generated/consoleApiSource';
|
||||||
const { source } = require(path.join(__dirname, '..', 'lib', 'generated', 'consoleApiSource'));
|
|
||||||
|
|
||||||
const fixtures = folio.extend();
|
const fixtures = folio.extend();
|
||||||
fixtures.context.override(async ({ context }, run) => {
|
fixtures.context.override(async ({ context }, run) => {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, expect } from './fixtures';
|
import { it, expect } from './fixtures';
|
||||||
import * as path from 'path';
|
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||||
|
|
||||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
|
||||||
|
|
||||||
it('should work with large DOM', async ({page, server}) => {
|
it('should work with large DOM', async ({page, server}) => {
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, expect } from './fixtures';
|
import { it, expect } from './fixtures';
|
||||||
import * as path from 'path';
|
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||||
|
|
||||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
|
||||||
|
|
||||||
it('should work for open shadow roots', async ({page, server}) => {
|
it('should work for open shadow roots', async ({page, server}) => {
|
||||||
await page.goto(server.PREFIX + '/deep-shadow.html');
|
await page.goto(server.PREFIX + '/deep-shadow.html');
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { it, expect } from './fixtures';
|
import { it, expect } from './fixtures';
|
||||||
import * as path from 'path';
|
import { selectorsV2Enabled } from '../src/server/common/selectorParser';
|
||||||
|
|
||||||
const { selectorsV2Enabled } = require(path.join(__dirname, '..', 'lib', 'server', 'common', 'selectorParser'));
|
|
||||||
|
|
||||||
it('should work', async ({page}) => {
|
it('should work', async ({page}) => {
|
||||||
await page.setContent(`<div>yo</div><div>ya</div><div>\nye </div>`);
|
await page.setContent(`<div>yo</div><div>ya</div><div>\nye </div>`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue