mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-23 15:41:32 +00:00
fix test
This commit is contained in:
@@ -1,34 +1,20 @@
|
|||||||
import * as puppeteer from 'puppeteer';
|
|
||||||
import { build } from '../../../api';
|
import { build } from '../../../api';
|
||||||
import * as assert from "assert";
|
import * as assert from "assert";
|
||||||
import { AppRunner } from '../AppRunner';
|
import * as fs from 'fs';
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
describe('with-sourcemaps-webpack', function() {
|
describe('with-sourcemaps', function() {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
|
||||||
let runner: AppRunner;
|
|
||||||
let page: puppeteer.Page;
|
|
||||||
let base: string;
|
|
||||||
|
|
||||||
// helpers
|
|
||||||
let start: () => Promise<void>;
|
|
||||||
let prefetchRoutes: () => Promise<void>;
|
|
||||||
let prefetch: (href: string) => Promise<void>;
|
|
||||||
let goto: (href: string) => Promise<void>;
|
|
||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
before(async () => {
|
before(async () => {
|
||||||
await build({ cwd: __dirname, bundler: 'webpack' });
|
await build({ cwd: __dirname, bundler: 'webpack' });
|
||||||
|
|
||||||
runner = new AppRunner(__dirname, '__sapper__/build/server/server.js');
|
|
||||||
({ base, page, start, prefetchRoutes, prefetch, goto } = await runner.start());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not put sourcemap files in service worker shell', async () => {
|
it('does not put sourcemap files in service worker shell', async () => {
|
||||||
const serviceWorker = await import(`${__dirname}/__sapper__/service-worker.js`);
|
const service_worker_source = fs.readFileSync(`${__dirname}/src/node_modules/@sapper/service-worker.js`, 'utf-8');
|
||||||
const shell: string[] = serviceWorker.shell;
|
const shell_source = /shell = (\[[\s\S]+?\])/.exec(service_worker_source)[1];
|
||||||
|
const shell = JSON.parse(shell_source);
|
||||||
|
|
||||||
assert.equal(shell.filter(_ => _.endsWith('.map')).length, 0,
|
assert.equal(shell.filter(_ => _.endsWith('.map')).length, 0,
|
||||||
'sourcemap files are not cached in SW');
|
'sourcemap files are not cached in SW');
|
||||||
@@ -37,7 +23,4 @@ describe('with-sourcemaps-webpack', function() {
|
|||||||
const sourcemapFiles = fs.readdirSync(clientShellDir).filter(_ => _.endsWith('.map'));
|
const sourcemapFiles = fs.readdirSync(clientShellDir).filter(_ => _.endsWith('.map'));
|
||||||
assert.ok(sourcemapFiles.length > 0, 'sourcemap files exist');
|
assert.ok(sourcemapFiles.length > 0, 'sourcemap files exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => runner.end());
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user