Options
All
  • Public
  • Public/Protected
  • All
Menu

Module TaskQueue

A queue of tasks to be carried out at a certain part of the suite or test.

Teardown

A TaskQueue used to maintain a list of tasks to execute at the end of the suite or test. These will execute regardless of passing or failing.

this.suite.teardown.register(() => {
   this.log('Worker teardown');
   return this.context.get().worker.teardown();
});

If registered in the suite, this will be carried out upon the suite (the collection of tests ending. You can also add individual teardowns within tests, that will execute when the individual test has ended. In this example here, within the test, we create an applciation, and after the test, we wish to remove that application:

example
 module.exports = {
     title: 'Example',
         tests: [
             {
                 title: 'Move device to another application',
                 run: async function(test) {
                     // create an app
                     await this.context.get().balena.sdk.models.application.create({
                         name: APP,
                         deviceType: DEVICE_TYPE,
                         organization: ORG,
                     });
                     // Register a teardown that will remove the test when the test ends
                     this.teardown.register(() => {
                         return this.context.get().balena.sdk.models.application.remove(APP);
                     });
                     // THE REST OF THE TEST CODE
                 }
             }
         ]
 }

Index

Namespaces

Properties

Properties

export=

export=: { Setup: TaskQueue; Teardown: Teardown }

Type declaration

  • Setup: TaskQueue
  • Teardown: Teardown

Generated using TypeDoc