Allows any value.
Sets up a property on an existing Mock. Allows getter and setter functions to be set. Enables get and set function call verification to be performed.
Sets up a static property on an existing Mock with constructor. Allows getter and setter functions to be set. Enables get and set function call verification to be performed.
Checks that the value is not undefined and not null. actualValue != null
Returns a string representation of a value.
Wraps an existing module and prepares it for use in jest.mock
jest.mock('../../relativeImportPath', () => require('@morgan-stanley/ts-mocking-bird').proxyJestModule( require.resolve('../../relativeImportPath'), ), );
Takes an existing function and wraps all functions and constructors. This allows us to replace the function or constructor after it has been imported into the system under test This will not replace statics on classes or replace constant values in the module
Replaces functions or constructors in a previously wrapped module. If a module is not wrapped a warning is logged and no replacements occur
Replaces properties (or functions) in the provided object Replacement is done in a call to 'beforeAll'. Properties are reverted to the original value in a call to 'afterAll'
The original object. Could be an import: 'import * as myImport from "./importLocation"'
Object containing functions or properties to replace
Replaces functions, classes or simple values in objects. This runs before each test allowing us to create a new mock object before each test and assert function calls
Example:
// SUT: import { sampleFunction, SampleClass} from "someImport";
export MyClass{ public getValue(){ return new SampleClass(); }
public getOtherValue(){
return sampleFunction();
}
}
// Test:
describe("test", () => {
import * as importToMock from "someImport";
replacePropertiesBeforeEach(() => {
const mockedClass = Mock.create
return [{package: importToMock, mocks: {SampleClass: mockedClass.mockConstructor, sampleFunction: mockedFunction}}]; });
})
a function used to setup your mocks and to return an array of import replacements
Replaces previously replaced module members
Mocks a function on an existing Mock. Allows function call verification to be performed later in the test. You can optionally set a mock function implementation that will be called.
Sets up a property on an existing Mock. Allows the value of the property to be defined. Enables get and set function call verification to be performed.
Mocks a staticfunction on an existing Mock. Allows function call verification to be performed later in the test. You can optionally set a mock function implementation that will be called.
Sets up a static property on an existing Mock. Allows the value of the property to be defined. Enables get and set function call verification to be performed.
Compares the expected value to the actual value with a strict equality check. actualValue === expectedValue
Checks that the value is not undefined. This will pass if the value is null (like jasmine does). actualValue !== undefined
Checks that the expected value is equal to the actual value using deep object comparison. actualValue => isEqual(actualValue, expectedValue)
Generated using TypeDoc
string value that is VERY unlikely to be a genuine value