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:
Dmitry Gozman 2020-12-28 11:14:33 -08:00 committed by GitHub
parent 94077e0e74
commit 4c11f5d885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 20 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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) => {

View File

@ -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(() => {

View File

@ -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');

View File

@ -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>`);