Options
All
  • Public
  • Public/Protected
  • All
Menu

Test descriptor class for tests running in the browser environment.

Hierarchy

  • TestDescriptorBrowser<this>
    • TestDescriptorBrowser

Index

Constructors

constructor

  • Parameters

    • Rest ...input: any[]

    Returns TestDescriptorBrowser

Properties

alsoPreload

A preload descriptor or an array of those. Defines what resources should be loaded into the test page in addition to the preload config, before executing the test.

defaultTimeout

defaultTimeout: number

A default timeout for various asynchronous actions, in milliseconds.

Default value is 15000ms.

failOnResourceLoadError

failOnResourceLoadError: boolean

When this config is set to true, the failures when loading various resources (script/link/img tags, etc) will be reported as failed assertions.

Default value is false.

isTodo

isTodo: boolean

Whether this test is "todo" or not. Todo tests are considered work in progress and expected to fail. The failed assertions in them are not reported. In opposite, the passed assertions from the todo tests are reported.

onAmbiguousQuery

onAmbiguousQuery: "warn" | "use_first" | "throw" = 'warn'

What to do, if an ActionTarget query has been resolved into multiple elements:

  • use_first - silently use the 1st one in the results, usually its the 1st element matching the query in the depth-first order of the DOM tree.
  • warn - use the 1st element, and issue a warning
  • throw - throw an exception

pageUrl

pageUrl: string

This config allows you to use the external web page for running the test. This page can be generated by your web application for example.

Currently, this config is only recognized when provided in the project file.

Important The url of the page is resolved relative to the url of the project file. See also the pageUrlRel config, which is resolved relative the test file.

Note, that Siesta is using "in-page" execution model for the tests - test is executed right "inside" the page. This means it has full and direct access to page internals, but also means test will not "survive" the page redirect.

If you need to test the page with arbitrary redirects, then instead write your tests as Node.js scripts and use the "classic" Playwright API to create the page instance and evalulate command of those libraries ("out-of-page" execution model). In the future releases, we'll provide an unified API for both on-page and out-of-page testing scenarios.

pageUrlRel

pageUrlRel: string

The relative version of the pageUrl config. The url of the external page, specified with this config, is resolved relative to the url of the test file. For example, for this setup:

project.plan({
url : 'dir/file.js',
pageUrlRel : 'page.html'
})

The resolved url for pageUrl will be: dir/page.html (resolved relative to dir/file.js)

See also pageUrl documentation for more details.

preload

A preload descriptor or an array of those. Defines what resources should be loaded into the test page, before executing the test.

IMPORTANT The url of the preload descriptor is resolved relative to the project file location (inside the directory of the project file). See also preloadRel config, the urls of which are resolved relative to the test file location.

Currently, this config is only recognized when provided in the project file.

IMPORTANT The preloading happens after the test file has been loaded into the page, but before any test starts. This means, if want to use the preloaded resources, the code accessing them should be placed inside any of the it, describe or beforeEach section. Using the preloaded resources at the top-level of the file won't work. For example:

// this test file preloads a file which defines a global constant `MY_CONSTANT`
import { beforeEach, it } from "../../browser.js"

// this will throw - `MY_CONSTANT` is not preloaded yet
const some = MY_CONSTANT + 1

// this will work correctly, test are launched after preload
it('My test', async t => {
const some = MY_CONSTANT + 1
})

Note, that if test descriptor has non-empty pageUrl option, then it will not inherit the preload option from parent descriptors or project, unless it has the preload config set to string inherit. If both pageUrl and preload are set on the project level (or on the directory), preload value still will be inherited.

preloadRel

The relative version of the preload config. The url of the preload descriptor, specified with this config, is resolved relative to the test file location (inside the directory of the test file). Similarly, if the preload config is specified on the directory descriptor, the url of the preload descriptor is resolved inside the parent directory of that directory.

See preload documentation for more details.

snooze

snooze: string | Date

Either a Date instance or a string, recognized by the Date constructor.

If this config is specified, and the test is running prior the specified date, the test will be switched to todo mode.

For example in the project file:

project.plan(
{
filename : 'some_test.t.js',
// choose the unsnooze date wisely
snooze : '2021-12-25'
}
)

in the test file:

it({
title : 'Some test',
snooze : '2022-01-01'
}, async t => {
...
})

title

title: string = ''

The human-readable title of this test.

url

url: string = ''

The url for this test, relative to the parent descriptor. It can also be an absolute url. By convention, Siesta tests should have *.t.js extension.

For the top-level descriptors, url is relative to the project file itself.

For example:

project.plan(
{
// relative to project file
url : 'some_directory',

items : [
// relative to `some_directory`
{ url : 'test_1.t.js' }
// or just:
'test_2.t.js',
]
}
)

waitForPollInterval

waitForPollInterval: number

A default poll interval for the waitFor assertion, in milliseconds.

Default value is 50ms.

waitForTimeout

waitForTimeout: number

A default timeout for the waitFor assertion, in milliseconds. If not provided, the defaultTimeout will be used.

Methods

initialize

  • Parameters

    Returns void

Static maybeNew

  • maybeNew<T>(props?: InstanceType<T> | Partial<InstanceType<T>>): InstanceType<T>
  • This is a type-safe static constructor method, accepting a single argument. If that argument is already an instance of this class - it is returned right away, otherwise the new constructor is used for instantiation.

    Type parameters

    Parameters

    • Optional props: InstanceType<T> | Partial<InstanceType<T>>

    Returns InstanceType<T>

Static new

  • new<T>(props?: Partial<InstanceType<T>>): InstanceType<T>
  • This is a type-safe static constructor method, accepting a single argument, with the object, corresponding to the class properties. It will generate a compilation error, if unknown property is provided.

    For example:

    class MyClass extends Base {
    prop : string
    }

    const instance : MyClass = MyClass.new({ prop : 'prop', wrong : 11 })

    will produce:

    TS2345: Argument of type '{ prop: string; wrong: number; }' is not assignable to parameter of type 'Partial<MyClass>'.
    Object literal may only specify known properties, and 'wrong' does not exist in type 'Partial<MyClass>'

    The only thing this constructor does is create an instance and call the initialize method on it, forwarding the first argument. The customization of instance is supposed to be performed in that method.

    Type parameters

    Parameters

    • Optional props: Partial<InstanceType<T>>

    Returns InstanceType<T>

Generated using TypeDoc