Capture screenshots while running karma tests

This commit is contained in:
Niklas von Hertzen
2017-08-30 21:31:51 +08:00
parent a41ba8852f
commit 23b6f29ecf
8 changed files with 71 additions and 23 deletions

View File

@@ -37,7 +37,7 @@ export class DocumentCloner {
if (backgroundImage.method === 'url') {
return this.imageLoader
.inlineImage(backgroundImage.args[0])
.then(src => (src ? `url("${src}")` : 'none'));
.then(img => (img ? `url("${img.src}")` : 'none'));
}
return Promise.resolve(
`${backgroundImage.prefix}${backgroundImage.method}(${backgroundImage.args.join(
@@ -54,9 +54,12 @@ export class DocumentCloner {
});
if (node instanceof HTMLImageElement) {
this.imageLoader.inlineImage(node.src).then(src => {
if (src && node instanceof HTMLImageElement) {
node.src = src;
this.imageLoader.inlineImage(node.src).then(img => {
if (img && node instanceof HTMLImageElement && node.parentNode) {
node.parentNode.replaceChild(
copyCSSStyles(node.style, img.cloneNode(false)),
node
);
}
});
}