firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Tests are ignored when passing imported Component or method to describe #177

Closed wesleylhandy closed 3 years ago

wesleylhandy commented 3 years ago

The Jest describe function takes two arguments. The name is typed as follows:

name: string | number | Function | jest.FunctionLike

This means you can pass the Component or Method being tested as the first argument within describe.

Recently, I can't remember the date, but vscode-jest-runner stopped recognizing the my outermost describe calls where I pass in the method/component being tested. All my tests were still being found, but they were being skipped when I clicked run. The describe name was being returned by the parse method as __unsupported__.

JestRunnerCodeLenseProvider.ts > provideCodeLenses

import { parse, ParsedNode } from 'jest-editor-support';
...
export class JestRunnerCodeLensProvider implements CodeLensProvider {  
  public async provideCodeLenses(document: TextDocument): Promise<CodeLens[]> {    
    const parseResults = parse(document.fileName, document.getText()).root.children;
    const codeLens = [];  
    parseResults.forEach(parseResult => codeLens.push(...getTestsBlocks(parseResult, parseResults)));  
    return codeLens;  
}}

Thus, the test runner would never find the actual test and run it.

Perhaps this is properly an issue for jest-editor-support but it is an ongoing issue here as well. It has made using this extension burdensome. There are good reasons for passing in the actual method/component to describe rather than simply a string.

firsttris commented 3 years ago

hey @wesleylhandy thx for reporting this issue

probably i don't get it completely.

how can i reproduce your issue?

maybe re-check if your issue still persists in version 0.4.35

wesleylhandy commented 3 years ago

@firsttris I just tested this morning with the most recent version 0.4.35 and it seems to be working now.

It was working as expected a little over a month ago, then stopped working, and now with recent update works as expected.

I might open a PR with the test case I am describing and add it to the tests for this extension.

firsttris commented 3 years ago

thx!

wesleylhandy commented 3 years ago

@firsttris Today, 0.4.39 - broken again.