Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

[Fixes #39] Issue where test names with ` are ignored #40

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/parser/codeParser.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { parse } from "@babel/parser";
import { parse, ParserOptions } from "@babel/parser";

const testTokens = ["describe", "it", "test"];

function codeParser(sourceCode) {
const parserOptions = {
plugins: [
"jsx",
"typescript"
],
const parserOptions: ParserOptions = {
plugins: ["jsx", "typescript"],
sourceType: "module",
tokens: true,
tokens: true
};
const ast = parse(sourceCode, parserOptions);

Expand All @@ -26,9 +23,19 @@ function codeParser(sourceCode) {
return;
}

let testNameToken;

const currentToken = ast.tokens[index + 2];

if (currentToken.value === undefined && currentToken.type.label === "`") {
testNameToken = ast.tokens[index + 3];
} else {
testNameToken = ast.tokens[index + 2];
}

return {
loc,
testName: ast.tokens[index + 2].value
testName: testNameToken.value
};
})
.filter(Boolean);
Expand Down