UNPKG

2.17 kBTypeScriptView Raw
1export interface SharedState {
2}
3/**
4 * A Mocha suite (or suites) run within a child iframe, but reported as if they
5 * are part of the current context.
6 */
7export default class ChildRunner {
8 private container?;
9 private eventListenersToRemoveOnClean;
10 private iframe?;
11 private onRunComplete;
12 share: SharedState | null;
13 state: 'initializing' | 'loading' | 'complete';
14 private timeoutId?;
15 private url;
16 parentScope: Window;
17 constructor(url: string, parentScope: Window);
18 /**
19 * Listeners added using this method will be removed on done()
20 *
21 * @param type event type
22 * @param listener object which receives a notification
23 * @param target event target
24 */
25 private addEventListener;
26 /**
27 * Removes all event listeners added by a method addEventListener defined
28 * on an instance of ChildRunner.
29 */
30 private removeAllEventListeners;
31 static loadTimeout: number;
32 private static byUrl;
33 /**
34 * @return {ChildRunner} The `ChildRunner` that was registered for this
35 * window.
36 */
37 static current(): ChildRunner | null;
38 /**
39 * @param {!Window} target A window to find the ChildRunner of.
40 * @param {boolean} traversal Whether this is a traversal from a child window.
41 * @return {ChildRunner} The `ChildRunner` that was registered for `target`.
42 */
43 static get(target: Window, traversal?: boolean): ChildRunner | null;
44 /**
45 * Loads and runs the subsuite.
46 *
47 * @param {function} done Node-style callback.
48 */
49 run(done: (error?: {}) => void): void;
50 /**
51 * Called when the sub suite's iframe has loaded (or errored during load).
52 *
53 * @param {*} error The error that occured, if any.
54 */
55 loaded(error?: {}): void;
56 /**
57 * Called in mocha/run.js when all dependencies have loaded, and the child is
58 * ready to start running tests
59 *
60 * @param {*} error The error that occured, if any.
61 */
62 ready(error?: {}): void;
63 /**
64 * Called when the sub suite's tests are complete, so that it can clean up.
65 */
66 done(): void;
67 signalRunComplete(error?: {}): void;
68}