Skip to content

Commit

Permalink
Improve test result match fallback in the imperfect world (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
connectdotz authored Jun 14, 2021
1 parent 847dcb4 commit cb41e37
Show file tree
Hide file tree
Showing 14 changed files with 1,226 additions and 367 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ git:
jobs:
- stage: "verify"
name: "verify"
node_js: "10"
node_js: "12"
os: osx
script: yarn danger ci

node_js:
- "10"
- "12"
- "lts/*"

os:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
}
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Please add your own contribution below inside the Master section
Bug-fixes within the same version aren't needed
## Master
-->

### 4.0.3
* add `--watchAll=false` to non-watch tasks - @connectdotz
* move save related operations to new SaveTextDocument event listeners to prevent duplicate firing and losing test state for watch-mode + clean-doc-save combination. - @connectdotz
* move testFile state to ResultProvider that provides a union of test-files and actual results, to be more robust even when there is a race condition when fileList comes after test run. - @connectdotz
* convert to upper-case drive letter for ProjectWorkspace rootPath - @connectdotz
* fix test file parsing for multiple array situation (#699) - @connectdotz
-->

* improve context match fallback: add name and location lookup as fallback for context matching. - @connectdotz
* fix test file parsing for multiple array situation (#699) - @connectdot
### 4.0.2
* fix debug problem for windows users (#707) - @connectdotz
* change *Run Related Tests* default keybinding to Ctrl-Alt/Option-T to avoid overriding default shortcuts. (#704) - @Agalin
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-jest",
"displayName": "Jest",
"description": "Use Facebook's Jest With Pleasure.",
"version": "4.0.2",
"version": "4.0.3",
"publisher": "Orta",
"engines": {
"vscode": "^1.45.0"
Expand Down Expand Up @@ -388,7 +388,7 @@
"dependencies": {
"istanbul-lib-coverage": "^3.0.0",
"istanbul-lib-source-maps": "^4.0.0",
"jest-editor-support": "^28.2.0",
"jest-editor-support": "^29.0.0",
"jest-snapshot": "^25.5.0",
"vscode-codicons": "^0.0.4"
},
Expand Down
13 changes: 5 additions & 8 deletions src/TestResults/TestResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { JestFileResults, JestTotalResults } from 'jest-editor-support';
import { FileCoverage } from 'istanbul-lib-coverage';
import * as path from 'path';
import { cleanAnsi, toLowerCaseDriveLetter } from '../helpers';
import { MatchEvent } from './match-node';

export interface Location {
/** Zero-based column number */
Expand All @@ -22,12 +23,6 @@ export interface TestIdentifier {
ancestorTitles: string[];
}

export type MatchResultReason =
| 'match-by-context'
| 'match-by-name'
| 'duplicate-names'
| 'no-matched-assertion';

export interface TestResult extends LocationRange {
name: string;

Expand All @@ -42,8 +37,10 @@ export interface TestResult extends LocationRange {

// multiple results for the given range, common for parameterized (.each) tests
multiResults?: TestResult[];
// record match or unmatch reason for this test result
reason?: MatchResultReason;

// matching process history
sourceHistory?: MatchEvent[];
assertionHistory?: MatchEvent[];
}

function testResultWithLowerCaseWindowsDriveLetter(testResult: JestFileResults): JestFileResults {
Expand Down
4 changes: 1 addition & 3 deletions src/TestResults/TestResultProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export class TestResultProvider implements JestExtSessionAware {
// no need to do groupByRange as the source block will not have blocks under the same location
return {
status: 'Unknown',
results: itBlocks.map((t) =>
match.toMatchResult(t, 'no assertion found', 'no-matched-assertion')
),
results: itBlocks.map((t) => match.toMatchResult(t, 'no assertion found', 'match-failed')),
};
}

Expand Down
Loading

0 comments on commit cb41e37

Please sign in to comment.