mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-11 14:52:26 +03:00
switch from puppeteer to playwright
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const PlaywrightEnvironment = require('jest-playwright-preset/lib/PlaywrightEnvironment').default;
|
||||
const { setupRollupTest, cleanupRollupTest } = require('./jest-browser.rollup.js');
|
||||
|
||||
const buildTests = [];
|
||||
|
||||
class BrowserRollupEnvironment extends PlaywrightEnvironment {
|
||||
constructor(envConfig, envContext) {
|
||||
super(envConfig, envContext);
|
||||
|
||||
this.watch = (envConfig.displayName.name || '').includes('-dev');
|
||||
this.ctx = envContext;
|
||||
this.cfg = envConfig;
|
||||
}
|
||||
|
||||
async setup() {
|
||||
const { testPath } = this.ctx;
|
||||
|
||||
if (!buildTests.includes(testPath)) {
|
||||
await cleanupRollupTest(testPath, this.cfg.cache);
|
||||
await setupRollupTest(this.cfg.rootDir, this.ctx.testPath, this.cfg.cache && this.cfg.cacheDirectory, this.watch);
|
||||
buildTests.push(testPath);
|
||||
}
|
||||
|
||||
await super.setup();
|
||||
}
|
||||
|
||||
async teardown() {
|
||||
await super.teardown();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BrowserRollupEnvironment;
|
||||
@@ -8,10 +8,10 @@ const rollupPluginHtml = require('@rollup/plugin-html');
|
||||
const rollupPluginStyles = require('rollup-plugin-styles');
|
||||
const rollupPluginServe = require('rollup-plugin-serve');
|
||||
const rollupPluginLivereload = require('rollup-plugin-livereload');
|
||||
const deploymentConfig = require('./jest-puppeteer.rollup.config.js');
|
||||
const deploymentConfig = require('./jest-browser.rollup.config.js');
|
||||
|
||||
const rollupConfigName = 'rollup.config.js';
|
||||
const cacheFilePrefix = 'jest-puppeteer-overlayscrollbars-cache-';
|
||||
const cacheFilePrefix = 'jest-browser-overlayscrollbars-cache-';
|
||||
const cacheEncoding = 'utf8';
|
||||
const cacheHash = 'md5';
|
||||
|
||||
@@ -194,7 +194,7 @@ const setupRollupTest = async (rootDir, testPath, cacheDir, watch) => {
|
||||
rollupPluginStyles(),
|
||||
...defaultConfig.pipeline,
|
||||
rollupPluginHtml({
|
||||
title: `Jest-Puppeteer: ${testName}`,
|
||||
title: `Jest-Browser: ${testName}`,
|
||||
fileName: deploymentConfig.html.output,
|
||||
template: genHtmlTemplateFunc(getHtmlFileContent),
|
||||
meta: [{ charset: 'utf-8' }, { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }],
|
||||
@@ -327,9 +327,9 @@ const setupRollupTest = async (rootDir, testPath, cacheDir, watch) => {
|
||||
}
|
||||
};
|
||||
|
||||
const cleanupRollupTest = (testPath, cache) => {
|
||||
const cleanupRollupTest = async (testPath, cache) => {
|
||||
if (!cache) {
|
||||
del(path.resolve(path.dirname(testPath), deploymentConfig.build));
|
||||
await del(path.resolve(path.dirname(testPath), deploymentConfig.build));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
jest.setTimeout(60000);
|
||||
context.setDefaultTimeout(60000);
|
||||
@@ -1,36 +0,0 @@
|
||||
const PuppeteerEnvironment = require('jest-environment-puppeteer');
|
||||
// const pti = require('puppeteer-to-istanbul');
|
||||
const { setupRollupTest, cleanupRollupTest } = require('./jest-puppeteer.rollup.js');
|
||||
|
||||
class PuppeteerRollupEnvironment extends PuppeteerEnvironment {
|
||||
constructor(envConfig, envContext) {
|
||||
super(envConfig, envContext);
|
||||
|
||||
this.watch = envConfig.displayName.name === 'puppeteer-dev';
|
||||
this.ctx = envContext;
|
||||
this.cfg = envConfig;
|
||||
}
|
||||
|
||||
async setup() {
|
||||
// setup
|
||||
await setupRollupTest(this.cfg.rootDir, this.ctx.testPath, this.cfg.cache && this.cfg.cacheDirectory, this.watch);
|
||||
await super.setup();
|
||||
|
||||
// coverage
|
||||
// const { page } = this.global;
|
||||
// await Promise.all([page.coverage.startCSSCoverage(), page.coverage.startJSCoverage()]);
|
||||
}
|
||||
|
||||
async teardown() {
|
||||
// coverage
|
||||
// const { page } = this.global;
|
||||
// const [jsCoverage, cssCoverage] = await Promise.all([page.coverage.stopJSCoverage(), page.coverage.stopCSSCoverage()]);
|
||||
// pti.write([...jsCoverage, ...cssCoverage], { includeHostname: true, storagePath: './.pptr' });
|
||||
|
||||
// cleanup
|
||||
cleanupRollupTest(this.ctx.testPath, this.cfg.cache);
|
||||
await super.teardown();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PuppeteerRollupEnvironment;
|
||||
@@ -1,4 +0,0 @@
|
||||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions;
|
||||
|
||||
jest.setTimeout(60000);
|
||||
setDefaultOptions({ timeout: 60000 });
|
||||
@@ -1,5 +1,5 @@
|
||||
const express = require('express');
|
||||
const deploymentConfig = require('./jest-puppeteer.rollup.config.js');
|
||||
const deploymentConfig = require('./jest-browser.rollup.config.js');
|
||||
|
||||
const app = express();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const path = require('path');
|
||||
const deploymentConfig = require('./jest-puppeteer.rollup.config.js');
|
||||
const deploymentConfig = require('./jest-browser.rollup.config.js');
|
||||
|
||||
module.exports = {
|
||||
process: (src, filePath) => {
|
||||
|
||||
Reference in New Issue
Block a user