MCPcopy
hub / github.com/meteor/meteor / fail

Method fail

packages/tinytest/tinytest.js:35–91  ·  view source on GitHub ↗
(doc)

Source from the content-addressed store, hash-verified

33 }
34
35 fail(doc) {
36 if (typeof doc === "string") {
37 // Some very old code still tries to call fail() with a
38 // string. Don't do this!
39 doc = { type: "fail", message: doc };
40 }
41
42 doc = {
43 ...doc,
44 ...this.extraDetails,
45 };
46
47 if (this.stop_at_offset === 0) {
48 if (Meteor.isClient) {
49 // Only supported on the browser for now..
50 var now = (+new Date);
51 debugger;
52 if ((+new Date) - now < 100)
53 alert("To use this feature, first enable your browser's debugger.");
54 }
55 this.stop_at_offset = null;
56 }
57 if (this.stop_at_offset)
58 this.stop_at_offset--;
59
60 // Get filename and line number of failure if we're using v8 (Chrome or
61 // Node).
62 if (Error.captureStackTrace) {
63 var savedPrepareStackTrace = Error.prepareStackTrace;
64 Error.prepareStackTrace = function(_, stack){ return stack; };
65 var err = new Error;
66 Error.captureStackTrace(err);
67 var stack = err.stack;
68 Error.prepareStackTrace = savedPrepareStackTrace;
69 for (var i = stack.length - 1; i >= 0; --i) {
70 var frame = stack[i];
71 // Heuristic: use the OUTERMOST line which is in a :tests.js
72 // file (this is less likely to be a test helper function).
73 const fileName = frame.getFileName();
74 if (fileName && fileName.match(/:tests\.js/)) {
75 doc.filename = fileName;
76 doc.line = frame.getLineNumber();
77 break;
78 }
79 }
80 }
81
82 this.onEvent({
83 type: (this.expecting_failure ? "expected_fail" : "fail"),
84 details: doc,
85 cookie: {name: this.test_case.name, offset: this.current_fail_count,
86 groupPath: this.test_case.groupPath,
87 shortName: this.test_case.shortName}
88 });
89 this.expecting_failure = false;
90 this.current_fail_count++;
91 }
92

Callers 15

equalMethod · 0.95
instanceOfMethod · 0.95
notInstanceOfMethod · 0.95
matchesMethod · 0.95
notMatchesMethod · 0.95
throwsMethod · 0.95
isTrueMethod · 0.95
isFalseMethod · 0.95
isNullMethod · 0.95
isNotNullMethod · 0.95
isUndefinedMethod · 0.95
isNotUndefinedMethod · 0.95

Calls 1

matchMethod · 0.45

Tested by

no test coverage detected