Skip to content
This repository was archived by the owner on Sep 14, 2024. It is now read-only.
This repository was archived by the owner on Sep 14, 2024. It is now read-only.

Add a context API for communication between init.spec and tests #108

Closed
@MagiMaster

Description

@MagiMaster

A beforeAll block within a test file can normally use upvalues to pass initialized objects to tests, but that won't work if it's in an init.spec.lua file. Instead, we can add a context object that's passed between the callbacks. This would also provide a mechanism to replace extraEnvironment (#78).

My suggestion for the context would be a write-once, hierarchical set of tables. Each describe node would create a new table that would be able to read from the parent node's context, but the callback of the describe node would not be able to access this node due to the describe/it ordering issues (it wouldn't break anything, but it'd be very confusing). The context would then be passed as an argument to each of the other types of callback. This would also mean that existing tests don't need to change as these callbacks currently take no arguments and can ignore the context until they need it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions