test: added testing via a browser (puppeteer)

This commit is contained in:
2023-12-03 10:42:51 +01:00
parent 2adfbee74b
commit e96c2248ee
27 changed files with 1281 additions and 123 deletions

26
test/util/code-output.ts Normal file
View File

@@ -0,0 +1,26 @@
import type {RollupBuild, OutputOptions, OutputAsset, OutputChunk, SourceMap} from "rollup";
export interface TestOutput{
code: string,
fileName: string,
source: any,
map: any
}
export const getCode = async (bundle: RollupBuild, outputOptions: OutputOptions): Promise<TestOutput[]> => {
const { output } = await bundle.generate(outputOptions || { format: 'cjs', exports: 'auto' });
return output.sort((a,b)=> {
if(a.fileName === b.fileName && (<OutputAsset>a).source !== (<OutputAsset>b).source){ return (<OutputAsset>a).source<(<OutputAsset>b).source?-1:1}
return a.fileName < b.fileName ? -1 : (a.fileName > b.fileName? 1 : 0);
}).map(chunk=> {
const { code, map } = (<OutputChunk>chunk);
const { fileName, source } = (<OutputAsset>chunk);
return {
code,
fileName,
source,
map
};
});
};