MCPcopy Create free account
hub / github.com/denoland/std / constructor

Method constructor

testing/_test_suite.ts:87–222  ·  view source on GitHub ↗
(describe: DescribeDefinition<T>)

Source from the content-addressed store, hash-verified

85 #registeredOptions: Deno.TestDefinition | undefined;
86
87 constructor(describe: DescribeDefinition<T>) {
88 this.describe = describe;
89 this.steps = [];
90 this.hasOnlyStep = false;
91
92 const { suite } = describe;
93 if (suite && !TestSuiteInternal.suites.has(suite.symbol)) {
94 throw new Error(
95 "Cannot construct Test Suite: suite does not represent a registered test suite",
96 );
97 }
98 const testSuite = suite
99 ? TestSuiteInternal.suites.get(suite.symbol)
100 : TestSuiteInternal.current;
101 this.symbol = Symbol();
102 TestSuiteInternal.suites.set(this.symbol, this);
103
104 const { fn, ignore } = describe;
105 if (ignore) {
106 const {
107 name,
108 only,
109 permissions,
110 sanitizeExit = globalSanitizersState.sanitizeExit,
111 sanitizeOps = globalSanitizersState.sanitizeOps,
112 sanitizeResources = globalSanitizersState.sanitizeResources,
113 } = describe;
114 const options: Deno.TestDefinition = {
115 name,
116 fn: async () => {},
117 ignore: true,
118 };
119 if (only !== undefined) {
120 options.only = only;
121 }
122 if (permissions !== undefined) {
123 options.permissions = permissions;
124 }
125 if (sanitizeExit !== undefined) {
126 options.sanitizeExit = sanitizeExit;
127 }
128 if (sanitizeOps !== undefined) {
129 options.sanitizeOps = sanitizeOps;
130 }
131 if (sanitizeResources !== undefined) {
132 options.sanitizeResources = sanitizeResources;
133 }
134 TestSuiteInternal.registerTest(options);
135 return;
136 }
137
138 if (fn) {
139 const temp = TestSuiteInternal.current;
140 TestSuiteInternal.current = this;
141 try {
142 // deno-lint-ignore no-explicit-any
143 const value = fn() as any;
144 if (value instanceof Promise) {

Callers

nothing calls this directly

Calls 9

registerTestMethod · 0.80
addStepMethod · 0.80
runMethod · 0.80
fnFunction · 0.70
hasMethod · 0.65
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected