test(upgrade): reduce flaky-ness by increasing timeout (#24937)
PR Close #24937
This commit is contained in:
parent
066fc6a0ca
commit
2505c077d7
|
@ -53,31 +53,48 @@ export function createWithEachNg1VersionFn(setNg1: typeof setAngularJSGlobal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(done => {
|
beforeAll(done => {
|
||||||
|
const restoreJasmineMethods = patchJasmineMethods();
|
||||||
|
const onSuccess = () => {
|
||||||
|
restoreJasmineMethods();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
const onError = (err: any) => {
|
||||||
|
restoreJasmineMethods();
|
||||||
|
done.fail(err);
|
||||||
|
};
|
||||||
|
|
||||||
// Load AngularJS before running tests.
|
// Load AngularJS before running tests.
|
||||||
files
|
files
|
||||||
.reduce(
|
.reduce(
|
||||||
(prev, file) => prev.then(() => new Promise<void>((resolve, reject) => {
|
(prev, file) => prev.then(() => new Promise<void>((resolve, reject) => {
|
||||||
const restoreMethods = patchJasmineMethods();
|
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.src = `base/angular_deps/node_modules/${file}`;
|
script.async = true;
|
||||||
script.onerror = reject;
|
script.onerror = reject;
|
||||||
script.onload = () => {
|
script.onload = () => {
|
||||||
document.body.removeChild(script);
|
document.body.removeChild(script);
|
||||||
restoreMethods();
|
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
script.src = `base/angular_deps/node_modules/${file}`;
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
})),
|
})),
|
||||||
Promise.resolve())
|
Promise.resolve())
|
||||||
.then(() => setNg1(win.angular))
|
.then(() => setNg1(win.angular))
|
||||||
.then(done, done.fail);
|
.then(onSuccess, onError);
|
||||||
});
|
|
||||||
|
// When Saucelabs is flaky, some browsers (esp. mobile) take some time to load and execute
|
||||||
|
// the AngularJS scripts. Specifying a higher timeout here, reduces flaky-ness.
|
||||||
|
}, 60000);
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
// In these tests we are loading different versions of AngularJS on the same window.
|
// `win.angular` will not be defined if loading the script in `berofeAll()` failed. In that
|
||||||
// AngularJS leaves an "expandoId" property on `document`, which can trick subsequent
|
// case, avoid causing another error in `afterAll()`, because the reporter only shows the
|
||||||
// `window.angular` instances into believing an app is already bootstrapped.
|
// most recent error (thus hiding the original, possibly more informative, error message).
|
||||||
win.angular.element.cleanData([document]);
|
if (win.angular) {
|
||||||
|
// In these tests we are loading different versions of AngularJS on the same window.
|
||||||
|
// AngularJS leaves an "expandoId" property on `document`, which can trick subsequent
|
||||||
|
// `window.angular` instances into believing an app is already bootstrapped.
|
||||||
|
win.angular.element.cleanData([document]);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove AngularJS to leave a clean state for subsequent tests.
|
// Remove AngularJS to leave a clean state for subsequent tests.
|
||||||
setNg1(undefined);
|
setNg1(undefined);
|
||||||
|
|
Loading…
Reference in New Issue