improve rrdom robustness (#1091)

This commit is contained in:
Yun Feng
2023-02-09 20:10:32 +11:00
committed by GitHub
parent 3a26e36f6f
commit 4ee86fe66d
7 changed files with 872 additions and 176 deletions

View File

@@ -4,9 +4,6 @@
import * as fs from 'fs';
import * as path from 'path';
import * as puppeteer from 'puppeteer';
import * as rollup from 'rollup';
import resolve from '@rollup/plugin-node-resolve';
import * as typescript from 'rollup-plugin-typescript2';
import { JSDOM } from 'jsdom';
import {
cdataNode,
@@ -29,8 +26,8 @@ import {
RRElement,
BaseRRNode as RRNode,
} from '../src';
import { compileTSCode } from './utils';
const _typescript = (typescript as unknown) as typeof typescript.default;
const printRRDomCode = `
/**
* Print the RRDom as a string.
@@ -61,7 +58,7 @@ describe('RRDocument for browser environment', () => {
describe('create a RRNode from a real Node', () => {
it('should support quicksmode documents', () => {
// seperate jsdom document as changes to the document would otherwise bleed into other tests
// separate jsdom document as changes to the document would otherwise bleed into other tests
const dom = new JSDOM();
const document = dom.window.document;
@@ -219,22 +216,7 @@ describe('RRDocument for browser environment', () => {
beforeAll(async () => {
browser = await puppeteer.launch();
const bundle = await rollup.rollup({
input: path.resolve(__dirname, '../src/index.ts'),
plugins: [
(resolve() as unknown) as rollup.Plugin,
(_typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}) as unknown) as rollup.Plugin,
],
});
const {
output: [{ code: _code }],
} = await bundle.generate({
name: 'rrdom',
format: 'iife',
});
code = _code;
code = await compileTSCode(path.resolve(__dirname, '../src/index.ts'));
});
afterAll(async () => {
await browser.close();