test(service-worker): do not create testing artifacts on environments that do not support SW (#27080)
The tests will not be run anyway, so the artifacts are never used and there might be errors if creating the testing artifacts relies on APIs that are not available in that environment (e.g. `URL`). PR Close #27080
This commit is contained in:
parent
415de9a291
commit
37a154e4e6
@ -21,6 +21,12 @@ import {take} from 'rxjs/operators';
|
|||||||
|
|
||||||
import {async_beforeEach, async_fit, async_it} from './async';
|
import {async_beforeEach, async_fit, async_it} from './async';
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||||
|
if (!SwTestHarness.envIsSupported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dist = new MockFileSystemBuilder().addFile('/only.txt', 'this is only').build();
|
const dist = new MockFileSystemBuilder().addFile('/only.txt', 'this is only').build();
|
||||||
|
|
||||||
const distUpdate = new MockFileSystemBuilder().addFile('/only.txt', 'this is only v2').build();
|
const distUpdate = new MockFileSystemBuilder().addFile('/only.txt', 'this is only v2').build();
|
||||||
@ -66,11 +72,7 @@ const server = new MockServerStateBuilder().withStaticFiles(dist).withManifest(m
|
|||||||
const serverUpdate =
|
const serverUpdate =
|
||||||
new MockServerStateBuilder().withStaticFiles(distUpdate).withManifest(manifestUpdate).build();
|
new MockServerStateBuilder().withStaticFiles(distUpdate).withManifest(manifestUpdate).build();
|
||||||
|
|
||||||
(function() {
|
|
||||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
|
||||||
if (!SwTestHarness.envIsSupported()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
describe('ngsw + companion lib', () => {
|
describe('ngsw + companion lib', () => {
|
||||||
let mock: MockServiceWorkerContainer;
|
let mock: MockServiceWorkerContainer;
|
||||||
let comm: NgswCommChannel;
|
let comm: NgswCommChannel;
|
||||||
|
@ -15,6 +15,12 @@ import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
|||||||
|
|
||||||
import {async_beforeEach, async_fit, async_it} from './async';
|
import {async_beforeEach, async_fit, async_it} from './async';
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||||
|
if (!SwTestHarness.envIsSupported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dist = new MockFileSystemBuilder()
|
const dist = new MockFileSystemBuilder()
|
||||||
.addFile('/foo.txt', 'this is foo')
|
.addFile('/foo.txt', 'this is foo')
|
||||||
.addFile('/bar.txt', 'this is bar')
|
.addFile('/bar.txt', 'this is bar')
|
||||||
@ -112,15 +118,7 @@ const serverSeqUpdate = new MockServerStateBuilder()
|
|||||||
|
|
||||||
const scope = new SwTestHarnessBuilder().withServerState(server).build();
|
const scope = new SwTestHarnessBuilder().withServerState(server).build();
|
||||||
|
|
||||||
function asyncWrap(fn: () => Promise<void>): (done: DoneFn) => void {
|
|
||||||
return (done: DoneFn) => { fn().then(() => done(), err => done.fail(err)); };
|
|
||||||
}
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
|
||||||
if (!SwTestHarness.envIsSupported()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
describe('data cache', () => {
|
describe('data cache', () => {
|
||||||
let scope: SwTestHarness;
|
let scope: SwTestHarness;
|
||||||
let driver: Driver;
|
let driver: Driver;
|
||||||
|
@ -18,6 +18,12 @@ import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
|||||||
|
|
||||||
import {async_beforeEach, async_fit, async_it} from './async';
|
import {async_beforeEach, async_fit, async_it} from './async';
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||||
|
if (!SwTestHarness.envIsSupported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dist =
|
const dist =
|
||||||
new MockFileSystemBuilder()
|
new MockFileSystemBuilder()
|
||||||
.addFile('/foo.txt', 'this is foo')
|
.addFile('/foo.txt', 'this is foo')
|
||||||
@ -42,7 +48,8 @@ const distUpdate =
|
|||||||
.addFile('/quuux.txt', 'this is quuux v2')
|
.addFile('/quuux.txt', 'this is quuux v2')
|
||||||
.addFile('/lazy/unchanged1.txt', 'this is unchanged (1)')
|
.addFile('/lazy/unchanged1.txt', 'this is unchanged (1)')
|
||||||
.addFile('/lazy/unchanged2.txt', 'this is unchanged (2)')
|
.addFile('/lazy/unchanged2.txt', 'this is unchanged (2)')
|
||||||
.addUnhashedFile('/unhashed/a.txt', 'this is unhashed v2', {'Cache-Control': 'max-age=10'})
|
.addUnhashedFile(
|
||||||
|
'/unhashed/a.txt', 'this is unhashed v2', {'Cache-Control': 'max-age=10'})
|
||||||
.addUnhashedFile('/ignored/file1', 'this is not handled by the SW')
|
.addUnhashedFile('/ignored/file1', 'this is not handled by the SW')
|
||||||
.addUnhashedFile('/ignored/dir/file2', 'this is not handled by the SW either')
|
.addUnhashedFile('/ignored/dir/file2', 'this is not handled by the SW either')
|
||||||
.build();
|
.build();
|
||||||
@ -69,7 +76,7 @@ const brokenManifest: Manifest = {
|
|||||||
|
|
||||||
// Manifest without navigation urls to test backward compatibility with
|
// Manifest without navigation urls to test backward compatibility with
|
||||||
// versions < 6.0.0.
|
// versions < 6.0.0.
|
||||||
export interface ManifestV5 {
|
interface ManifestV5 {
|
||||||
configVersion: number;
|
configVersion: number;
|
||||||
appData?: {[key: string]: string};
|
appData?: {[key: string]: string};
|
||||||
index: string;
|
index: string;
|
||||||
@ -214,11 +221,7 @@ const server404 = new MockServerStateBuilder().withStaticFiles(dist).build();
|
|||||||
const manifestHash = sha1(JSON.stringify(manifest));
|
const manifestHash = sha1(JSON.stringify(manifest));
|
||||||
const manifestUpdateHash = sha1(JSON.stringify(manifestUpdate));
|
const manifestUpdateHash = sha1(JSON.stringify(manifestUpdate));
|
||||||
|
|
||||||
(function() {
|
|
||||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
|
||||||
if (!SwTestHarness.envIsSupported()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
describe('Driver', () => {
|
describe('Driver', () => {
|
||||||
let scope: SwTestHarness;
|
let scope: SwTestHarness;
|
||||||
let driver: Driver;
|
let driver: Driver;
|
||||||
|
@ -15,6 +15,7 @@ import {async_beforeEach, async_fit, async_it} from './async';
|
|||||||
if (!SwTestHarness.envIsSupported()) {
|
if (!SwTestHarness.envIsSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('IdleScheduler', () => {
|
describe('IdleScheduler', () => {
|
||||||
let scope: SwTestHarness;
|
let scope: SwTestHarness;
|
||||||
let idle: IdleScheduler;
|
let idle: IdleScheduler;
|
||||||
|
@ -14,6 +14,12 @@ import {SwTestHarness, SwTestHarnessBuilder} from '../testing/scope';
|
|||||||
|
|
||||||
import {async_fit, async_it} from './async';
|
import {async_fit, async_it} from './async';
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
||||||
|
if (!SwTestHarness.envIsSupported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dist = new MockFileSystemBuilder()
|
const dist = new MockFileSystemBuilder()
|
||||||
.addFile('/foo.txt', 'this is foo')
|
.addFile('/foo.txt', 'this is foo')
|
||||||
.addFile('/bar.txt', 'this is bar')
|
.addFile('/bar.txt', 'this is bar')
|
||||||
@ -28,12 +34,6 @@ const scope = new SwTestHarnessBuilder().withServerState(server).build();
|
|||||||
const db = new CacheDatabase(scope, scope);
|
const db = new CacheDatabase(scope, scope);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
// Skip environments that don't support the minimum APIs needed to run the SW tests.
|
|
||||||
if (!SwTestHarness.envIsSupported()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
describe('prefetch assets', () => {
|
describe('prefetch assets', () => {
|
||||||
let group: PrefetchAssetGroup;
|
let group: PrefetchAssetGroup;
|
||||||
let idle: IdleScheduler;
|
let idle: IdleScheduler;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user