1 | /// <reference types="jest" />
|
2 | import type * as d from '@stencil/core/internal';
|
3 | import { InMemoryFileSystem } from '../compiler/sys/in-memory-fs';
|
4 | export declare function shuffleArray(array: any[]): any[];
|
5 | /**
|
6 | * Testing utility to validate the existence of some provided file paths using a specific file system
|
7 | *
|
8 | * @param fs the file system to use to validate the existence of some files
|
9 | * @param filePaths the paths to validate
|
10 | * @throws when one or more of the provided file paths cannot be found
|
11 | */
|
12 | export declare function expectFilesExist(fs: InMemoryFileSystem, filePaths: string[]): void;
|
13 | /**
|
14 | * Testing utility to validate the non-existence of some provided file paths using a specific file system
|
15 | *
|
16 | * @param fs the file system to use to validate the non-existence of some files
|
17 | * @param filePaths the paths to validate
|
18 | * @throws when one or more of the provided file paths is found
|
19 | */
|
20 | export declare function expectFilesDoNotExist(fs: InMemoryFileSystem, filePaths: string[]): void;
|
21 | export declare function getAppScriptUrl(config: d.ValidatedConfig, browserUrl: string): string;
|
22 | export declare function getAppStyleUrl(config: d.ValidatedConfig, browserUrl: string): string;
|
23 | /**
|
24 | * Utility for silencing `console` functions in tests.
|
25 | *
|
26 | * When this function is first called it grabs a reference to the `log`,
|
27 | * `error`, and `warn` functions on `console` and then returns a per-test setup
|
28 | * function which sets up a fresh set of mocks (via `jest.fn()`) and then
|
29 | * assigns them to each of these functions. This setup function will return a
|
30 | * reference to each of the three mock functions so tests can make assertions
|
31 | * about their calls and so on.
|
32 | *
|
33 | * Because references to the original `.log`, `.error`, and `.warn` functions
|
34 | * exist in closure within the function, it can use an `afterAll` call to clean
|
35 | * up after itself and ensure that the original implementations are restored
|
36 | * after the test suite finishes.
|
37 | *
|
38 | * An example of using this to silence log statements in a single test could look
|
39 | * like this:
|
40 | *
|
41 | * ```ts
|
42 | * describe("my-test-suite", () => {
|
43 | * const setupConsoleMocks = setupConsoleMocker()
|
44 | *
|
45 | * it("should log a message", () => {
|
46 | * const { logMock } = setupConsoleMocks();
|
47 | * myFunctionWhichLogs(foo, bar);
|
48 | * expect(logMock).toBeCalledWith('my log message');
|
49 | * })
|
50 | * })
|
51 | * ```
|
52 | *
|
53 | * @returns a per-test mock setup function
|
54 | */
|
55 | export declare function setupConsoleMocker(): ConsoleMocker;
|
56 | interface ConsoleMocker {
|
57 | (): {
|
58 | logMock: jest.Mock<typeof console.log>;
|
59 | warnMock: jest.Mock<typeof console.warn>;
|
60 | errorMock: jest.Mock<typeof console.error>;
|
61 | };
|
62 | }
|
63 | /**
|
64 | * the callback that `withSilentWarn` expects to receive. Basically receives a mock
|
65 | * as its argument and returns a `Promise`, the value of which is returns by `withSilentWarn`
|
66 | * as well.
|
67 | */
|
68 | declare type SilentWarnFunc<T> = (mock: jest.Mock<typeof console.warn>) => Promise<T>;
|
69 | /**
|
70 | * Wrap a single callback with a silent `console.warn`. The callback passed in
|
71 | * receives the mocking function as an argument, so you can easily make assertions
|
72 | * that it is called if necessary.
|
73 | *
|
74 | * @param cb a callback which `withSilentWarn` will call after replacing `console.warn`
|
75 | * with a mock.
|
76 | * @returns a Promise wrapping the return value of the callback
|
77 | */
|
78 | export declare function withSilentWarn<T>(cb: SilentWarnFunc<T>): Promise<T>;
|
79 | export {};
|