MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / evalScripts

Method evalScripts

tests/helpers/dist-checker.js:33–71  ·  view source on GitHub ↗
(timeout = 15000)

Source from the content-addressed store, hash-verified

31 }
32
33 evalScripts(timeout = 15000) {
34 this._evalHtml({
35 url: `file://.`,
36 runScripts: 'dangerously',
37 resources: new CustomResourceLoader(this.distPath),
38 });
39
40 // ember-data expects window.crypto to exists however JSDom does not
41 // impliment this: https://github.com/jsdom/jsdom/issues/1612
42 this.dom.window.crypto = () => {};
43 return new Promise((resolve, reject) => {
44 // reject if the scripts take longer than 15 seconds to load.
45 let timeoutId = setTimeout(() => {
46 reject(
47 new AssertionError({
48 operator: 'evalScripts[Timeout]',
49 message: `[dist-checker:${this.distPath}] timeout exceeded: ${timeout}`,
50 stackStartFn: this.evalScripts,
51 })
52 );
53 }, timeout);
54
55 this.dom.window.addEventListener('error', (e) => {
56 reject(
57 new AssertionError({
58 operator: 'evalScripts',
59 // this `e` has no stack, so we must make due
60 message: `error thrown during evalScript of '${this.distPath}' \n error details: \n message: '${e.message}'\n file: '${e.filename}:${e.colno}'`,
61 stackStartFn: this.evalScripts,
62 })
63 );
64 });
65
66 this.dom.window.addEventListener('load', () => {
67 clearTimeout(timeoutId);
68 return resolve();
69 });
70 });
71 }
72
73 get window() {
74 return this.dom.window;

Callers 1

Calls 1

_evalHtmlMethod · 0.95

Tested by

no test coverage detected