Skip to content

Commit b0e2b65

Browse files
fix: don't import from @stencil/core/internal/testing
1 parent 968cf7f commit b0e2b65

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
// File explorer settings
3535
"files.exclude": {
3636
"**/node_modules": true,
37-
"**/dist": true,
3837
"**/www": true,
3938
"**/.stencil": true,
4039
"**/coverage": true,

src/environment.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import type {
88
MockWindow,
99
} from '@stencil/core/mock-doc';
1010

11-
type MockStorage = ReturnType<typeof mockWindow>['localStorage'];
12-
type MockEvent = ReturnType<typeof mockWindow>['Event'];
13-
type MockTimeout = ReturnType<typeof mockWindow>['setTimeout'];
14-
type MockSetInterval = ReturnType<typeof mockWindow>['setInterval'];
11+
interface MockStorage {
12+
localStorage: Storage;
13+
sessionStorage: Storage;
14+
}
15+
16+
interface MockEvent {
17+
Event: Event;
18+
}
1519

1620
/**
1721
* Extended global object that includes both Node.js globals and DOM APIs
@@ -68,16 +72,16 @@ export class StencilEnvironment {
6872
this.global.document = win.document as unknown as MockDocument;
6973
this.global.HTMLElement = win.HTMLElement;
7074
this.global.customElements = win.customElements;
71-
this.global.Event = win.Event;
75+
this.global.Event = win.Event as unknown as MockEvent;
7276
this.global.CustomEvent = win.CustomEvent;
7377
this.global.MouseEvent = win.MouseEvent;
7478
this.global.KeyboardEvent = win.KeyboardEvent;
7579
this.global.addEventListener = win.addEventListener.bind(win) as any;
7680
this.global.removeEventListener = win.removeEventListener.bind(win);
7781
this.global.requestAnimationFrame = win.requestAnimationFrame.bind(win);
7882
this.global.cancelAnimationFrame = win.cancelAnimationFrame.bind(win);
79-
this.global.localStorage = win.localStorage;
80-
this.global.sessionStorage = win.sessionStorage;
83+
this.global.localStorage = win.localStorage as unknown as MockStorage;
84+
this.global.sessionStorage = win.sessionStorage as unknown as MockStorage;
8185
this.global.location = win.location;
8286
this.global.history = win.history;
8387
this.global.navigator = win.navigator;
@@ -87,9 +91,9 @@ export class StencilEnvironment {
8791
this.global.console = console;
8892

8993
// Set up timing functions
90-
this.global.setTimeout = win.setTimeout.bind(win) as MockTimeout;
94+
this.global.setTimeout = win.setTimeout.bind(win) as unknown as typeof setTimeout;
9195
this.global.clearTimeout = win.clearTimeout.bind(win);
92-
this.global.setInterval = win.setInterval.bind(win) as MockSetInterval;
96+
this.global.setInterval = win.setInterval.bind(win) as unknown as typeof setInterval;
9397
this.global.clearInterval = win.clearInterval.bind(win);
9498

9599
// Set up URL

0 commit comments

Comments
 (0)