MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / assertThrowsRegExp

Function assertThrowsRegExp

apps/automated/src/tk-unit.ts:328–343  ·  view source on GitHub ↗
(testFunc: () => void, assertMessage?: string, expectedMessage?: RegExp)

Source from the content-addressed store, hash-verified

326}
327
328export function assertThrowsRegExp(testFunc: () => void, assertMessage?: string, expectedMessage?: RegExp) {
329 let actualError: Error;
330 try {
331 testFunc();
332 } catch (e) {
333 actualError = e;
334 }
335
336 if (!actualError) {
337 throw new Error('Missing expected exception. ' + assertMessage);
338 }
339
340 if (expectedMessage && !expectedMessage.test(actualError.message)) {
341 throw new Error('Got unwanted exception. Actual error: ' + actualError.message + ' Expected to match: ' + expectedMessage);
342 }
343}
344
345export function wait(seconds: number): void {
346 waitUntilReady(() => false, seconds, false);

Callers 1

assertThrowsFunction · 0.85

Calls 2

testFuncFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected