On this page

C

SuiteContext

History

An instance of SuiteContext is passed to each suite function in order to interact with the test runner. However, the SuiteContext constructor is not exposed as part of the API.

P

context.filePath

History

The absolute path of the test file that created the current suite. If a test file imports additional modules that generate suites, the imported suites will return the path of the root test file.

P

context.fullName

History

The name of the suite and each of its ancestors, separated by >.

P

context.name

History

The name of the suite.

P

context.signal

History

Can be used to abort test subtasks when the test has been aborted.

P

context.passed

History
Type:boolean

Indicates whether the suite and all of its subtests have passed.

P

context.attempt

History
Type:number

The attempt number of the suite. This value is zero-based, so the first attempt is 0, the second attempt is 1, and so on. This property is useful in conjunction with the --test-rerun-failures option to determine the attempt number of the current run.

M

context.diagnostic

History
context.diagnostic(message): void
Attributes
message:string
A diagnostic message to output.

Output a diagnostic message. This is typically used for logging information about the current suite or its tests.

test.describe('my suite', (suite) => {
  suite.diagnostic('Suite diagnostic message');
});
M

context.log

History
context.log(message, data?): void
Attributes
message:string
Message to be reported.
data:any
Optional structured payload attached to the message. The test runner passes it through untouched.

Write a log message to the output. The resulting 'test:log' event is emitted immediately, in the order that the tests execute.

test.describe('my suite', (suite) => {
  suite.log('Suite log message');
});