2020-10-06 10:47:16 +00:00
|
|
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-08-09 10:00:19 +00:00
|
|
|
import 'jest-preset-angular';
|
2021-02-02 17:42:25 +00:00
|
|
|
|
2021-03-15 13:31:00 +00:00
|
|
|
import { setCreateSingletonMethodProxy } from '@singletons';
|
|
|
|
|
2021-02-02 17:42:25 +00:00
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.debug = () => {
|
|
|
|
// Silence.
|
|
|
|
};
|
2021-03-15 13:31:00 +00:00
|
|
|
|
2021-05-25 09:49:09 +00:00
|
|
|
// eslint-disable-next-line no-console, jest/no-jasmine-globals, @typescript-eslint/no-explicit-any
|
2021-08-11 12:32:22 +00:00
|
|
|
console.error = (...args: any[]) => fail(args.map(a => String(a)).join(''));
|
2021-05-25 09:49:09 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-jasmine-globals
|
|
|
|
process.on('unhandledRejection', error => fail(error));
|
|
|
|
|
2021-03-15 13:31:00 +00:00
|
|
|
// Override the method to create singleton method proxies in order to facilitate setting up
|
|
|
|
// test expectations about method calls.
|
|
|
|
setCreateSingletonMethodProxy(
|
|
|
|
(instance, method, property) =>
|
|
|
|
instance[`mock_${String(property)}`] =
|
|
|
|
instance[`mock_${String(property)}`] ??
|
|
|
|
jest.fn((...args) => method.call(instance, ...args)),
|
|
|
|
);
|