Skip to content

Commit 0a608fd

Browse files
committed
test(wtr): handle endpoint to make logs quieter
1 parent 1c3e183 commit 0a608fd

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

packages/@lwc/integration-not-karma/configs/plugins/serve-integration.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ export default {
118118
async serve(ctx) {
119119
if (ctx.path.endsWith('.spec.js')) {
120120
return await transform(ctx);
121+
} else if (ctx.path === '/test_api_sanitizeAttribute') {
122+
// The test in /test/api/sanitizeAttribute makes network requests
123+
// The returned value doesn't matter; this is just to avoid
124+
// unnecessary logging output
125+
return '';
121126
}
122127
},
123128
};

packages/@lwc/integration-not-karma/test/api/sanitizeAttribute/index.spec.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* The URLs used in test are handled by the `serve` method defined in `serve-integration.js`.
3+
* What they serve doesn't matter, it's just to avoid a 404 warning logged to console
4+
*/
15
import {
26
createElement,
37
// Spy is created in a mock file and injected with the import map plugin
@@ -49,7 +53,7 @@ scenarios.forEach(({ type, attrName, tagName, Ctor }) => {
4953
document.body.appendChild(elm);
5054

5155
const use = elm.shadowRoot.querySelector('use');
52-
expect(use.getAttribute(attrName)).toBe('/foo');
56+
expect(use.getAttribute(attrName)).toBe('/test_api_sanitizeAttribute?foo');
5357
});
5458

5559
it('receives the right parameters', () => {
@@ -60,18 +64,18 @@ scenarios.forEach(({ type, attrName, tagName, Ctor }) => {
6064
'use',
6165
'http://www.w3.org/2000/svg',
6266
attrName,
63-
'/foo'
67+
'/test_api_sanitizeAttribute?foo'
6468
);
6569
});
6670

6771
it('replace the original attribute value with a string', () => {
68-
sanitizeAttributeSpy.mockReturnValue('/bar');
72+
sanitizeAttributeSpy.mockReturnValue('/test_api_sanitizeAttribute?bar');
6973

7074
const elm = createElement(tagName, { is: Ctor });
7175
document.body.appendChild(elm);
7276

7377
const use = elm.shadowRoot.querySelector('use');
74-
expect(use.getAttribute(attrName)).toBe('/bar');
78+
expect(use.getAttribute(attrName)).toBe('/test_api_sanitizeAttribute?bar');
7579
});
7680

7781
it('replace the original attribute value with undefined', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LightningElement } from 'lwc';
22

33
export default class extends LightningElement {
4-
href = '/foo';
4+
href = '/test_api_sanitizeAttribute?foo';
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<svg>
3-
<use href="/foo"></use>
3+
<use href="/test_api_sanitizeAttribute?foo"></use>
44
</svg>
55
</template>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LightningElement } from 'lwc';
22

33
export default class extends LightningElement {
4-
href = '/foo';
4+
href = '/test_api_sanitizeAttribute?foo';
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<svg>
3-
<use xlink:href="/foo"></use>
3+
<use xlink:href="/test_api_sanitizeAttribute?foo"></use>
44
</svg>
55
</template>

0 commit comments

Comments
 (0)