jstest

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FuncDescribe = "describe"
	FuncIt       = "it"
	FuncTest     = "test"

	ModifierSkip = "skip"
	ModifierOnly = "only"
	ModifierEach = "each"
	ModifierTodo = "todo"

	DynamicCasesSuffix = " (dynamic cases)"
)

Variables

View Source
var FocusedFunctionAliases = map[string]string{
	"fdescribe": FuncDescribe,
	"fit":       FuncIt,
}
View Source
var JestPlaceholderPattern = regexp.MustCompile(`%[sdpji#%]`)
View Source
var SkippedFunctionAliases = map[string]string{
	"xdescribe": FuncDescribe,
	"xit":       FuncIt,
	"xtest":     FuncTest,
}
View Source
var SupportedExtensions = map[string]bool{
	".ts":  true,
	".tsx": true,
	".js":  true,
	".jsx": true,
}

Functions

func AddSuiteToTarget

func AddSuiteToTarget(suite domain.TestSuite, parentSuite *domain.TestSuite, file *domain.TestFile)

AddSuiteToTarget adds a suite to the appropriate parent (suite or file).

func AddTestToTarget

func AddTestToTarget(test domain.Test, parentSuite *domain.TestSuite, file *domain.TestFile)

AddTestToTarget adds a test to the appropriate parent (suite or file).

func DetectLanguage

func DetectLanguage(filename string) domain.Language

DetectLanguage determines the programming language based on file extension.

func ExtractArrayContent

func ExtractArrayContent(node *sitter.Node, source []byte) string

func ExtractArrayElements

func ExtractArrayElements(arrayNode *sitter.Node, source []byte) []string

func ExtractEachTestCases

func ExtractEachTestCases(args *sitter.Node, source []byte) []string

func ExtractTestName

func ExtractTestName(args *sitter.Node, source []byte) string

func FindCallback

func FindCallback(args *sitter.Node) *sitter.Node

func FormatEachName

func FormatEachName(template, data string) string

func IsTestFile

func IsTestFile(filename string) bool

func Parse

func Parse(ctx context.Context, source []byte, filename string, framework string) (*domain.TestFile, error)

Parse is the main entry point for parsing JavaScript/TypeScript test files.

func ParseCallbackBody

func ParseCallbackBody(callback *sitter.Node, source []byte, filename string, file *domain.TestFile, suite *domain.TestSuite)

ParseCallbackBody parses the body of a callback function.

func ParseFunctionName

func ParseFunctionName(node *sitter.Node, source []byte) (string, domain.TestStatus, string)

func ParseIdentifierFunction

func ParseIdentifierFunction(node *sitter.Node, source []byte) (string, domain.TestStatus, string)

func ParseMemberExpressionFunction

func ParseMemberExpressionFunction(node *sitter.Node, source []byte) (string, domain.TestStatus, string)

func ParseModifierStatus

func ParseModifierStatus(modifier string) domain.TestStatus

func ParseNestedMemberExpression

func ParseNestedMemberExpression(obj, prop *sitter.Node, source []byte) (string, domain.TestStatus, string)

func ParseNode

func ParseNode(node *sitter.Node, source []byte, filename string, file *domain.TestFile, currentSuite *domain.TestSuite)

ParseNode recursively traverses the AST to find and process test definitions.

func ParseSimpleMemberExpression

func ParseSimpleMemberExpression(obj, prop *sitter.Node, source []byte) (string, domain.TestStatus, string)

func ProcessCallExpression

func ProcessCallExpression(node *sitter.Node, source []byte, filename string, file *domain.TestFile, currentSuite *domain.TestSuite)

ProcessCallExpression processes a call expression node to extract test/suite definitions.

func ProcessEachCall

func ProcessEachCall(outerCall, innerCall, outerArgs *sitter.Node, source []byte, filename string, file *domain.TestFile, currentSuite *domain.TestSuite)

ProcessEachCall handles .each() call patterns for both describe and test/it.

func ProcessEachSuites

func ProcessEachSuites(callNode *sitter.Node, testCases []string, nameTemplate string, callback *sitter.Node, source []byte, filename string, file *domain.TestFile, parentSuite *domain.TestSuite, status domain.TestStatus, modifier string)

ProcessEachSuites creates multiple suites from a describe.each() call.

func ProcessEachTests

func ProcessEachTests(callNode *sitter.Node, testCases []string, nameTemplate string, filename string, file *domain.TestFile, parentSuite *domain.TestSuite, status domain.TestStatus, modifier string)

ProcessEachTests creates multiple tests from a .each() call.

func ProcessSuite

func ProcessSuite(callNode *sitter.Node, args *sitter.Node, source []byte, filename string, file *domain.TestFile, parentSuite *domain.TestSuite, status domain.TestStatus, modifier string)

ProcessSuite creates a test suite from a call expression. Handles both regular suites with callbacks and pending suites without callbacks.

func ProcessTest

func ProcessTest(callNode *sitter.Node, args *sitter.Node, source []byte, filename string, file *domain.TestFile, parentSuite *domain.TestSuite, status domain.TestStatus, modifier string)

ProcessTest creates a test from a call expression.

func ResolveEachNames

func ResolveEachNames(template string, testCases []string) []string

ResolveEachNames generates test names from a template and test cases.

func UnquoteString

func UnquoteString(text string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL