(path)
| 269 | name: 'test-gate-pragma', |
| 270 | visitor: { |
| 271 | ExpressionStatement(path) { |
| 272 | const statement = path.node; |
| 273 | const expression = statement.expression; |
| 274 | if (expression.type === 'CallExpression') { |
| 275 | const callee = expression.callee; |
| 276 | switch (callee.type) { |
| 277 | case 'Identifier': { |
| 278 | if ( |
| 279 | callee.name === 'test' || |
| 280 | callee.name === 'it' || |
| 281 | callee.name === 'fit' |
| 282 | ) { |
| 283 | const comments = getComments(path); |
| 284 | if (comments !== undefined) { |
| 285 | const condition = buildGateCondition(comments); |
| 286 | if (condition !== null) { |
| 287 | callee.name = |
| 288 | callee.name === 'fit' ? '_test_gate_focus' : '_test_gate'; |
| 289 | expression.arguments = [ |
| 290 | t.arrowFunctionExpression( |
| 291 | [t.identifier('ctx')], |
| 292 | condition |
| 293 | ), |
| 294 | ...expression.arguments, |
| 295 | ]; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | break; |
| 300 | } |
| 301 | case 'MemberExpression': { |
| 302 | if ( |
| 303 | callee.object.type === 'Identifier' && |
| 304 | (callee.object.name === 'test' || |
| 305 | callee.object.name === 'it') && |
| 306 | callee.property.type === 'Identifier' && |
| 307 | callee.property.name === 'only' |
| 308 | ) { |
| 309 | const comments = getComments(path); |
| 310 | if (comments !== undefined) { |
| 311 | const condition = buildGateCondition(comments); |
| 312 | if (condition !== null) { |
| 313 | statement.expression = t.callExpression( |
| 314 | t.identifier('_test_gate_focus'), |
| 315 | [ |
| 316 | t.arrowFunctionExpression( |
| 317 | [t.identifier('ctx')], |
| 318 | condition |
| 319 | ), |
| 320 | ...expression.arguments, |
| 321 | ] |
| 322 | ); |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | break; |
| 327 | } |
| 328 | } |
nothing calls this directly
no test coverage detected