1.0.164 • Published 11 months ago

@nsshunt/stsrunnerframework v1.0.164

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

stsrunnerframework

terminated - this means the process has been terminated and no end-of-process steps should execute such as reports etc.

stopped - end the test and report as if completed normnally

State Machine

---
config:
  theme: neo
  look: neo
title: STSRunnerFramework
---
stateDiagram
  direction TB
  [*] --> Created:Select Start
  Created --> Running
  Created --> Error:Error Caught
  Running --> Completed:Iterations Exhausted
  Running --> Error:Error Caught
  Running --> Stopped:Select Stop
  Completed --> [*]
  Running --> Paused:Select Pause
  Paused --> Running:Select Resume
  Paused --> Paused:Select Execute or Reset
  Paused --> Stopped:Select Stop
  Running --> Terminated:Select Terminate
  Paused --> Terminated:Select Terminate
  Paused --> Completed:Select Execute<br>Iterations Exhausted
  Terminated --> [*]
  Error --> [*]
  Stopped --> [*]

Nodejs Factory Instance Example

/* eslint @typescript-eslint/no-unused-vars: 0,  @typescript-eslint/no-explicit-any: 0 */  // --> OFF
import { IRunnerInstance, ITestRunnerTelemetryPayload, eIWMessageCommands, WorkerInstance } from './../index'
import { TestCase01 } from './testCase01'

import isNode from 'detect-node'

import { parentPort } from 'worker_threads';

export class WorkerTestCases extends WorkerInstance {
    constructor() {
        super()
    }

    override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
        const { runner } = testRunnerTelemetryPayload;
        switch (runner.options.testType) {
        case 'TestCase01' :
            return new TestCase01(this, runner)
        }
        return null;
    }
}

const worker = new WorkerTestCases();

parentPort?.on('message', (data: any) => {
    if (isNode) {
        const { command, payload } = data;
        if (command === eIWMessageCommands.MessagePort) {
            payload.port.on('message', (data: any) => {
                worker.ProcessMessage(data);
            });
            worker.ProcessMessage(data);
        } else {
            throw new Error(`Invalid command: [${command}]`)
        }
    }
});

Agent Factory Instance Example

/* eslint @typescript-eslint/no-unused-vars: 0,  @typescript-eslint/no-explicit-any: 0 */  // --> OFF
import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance, eIWMessageCommands } from './../index'
import { TestCase01 } from './testCase01'

export class WorkerTestCases extends WorkerInstance {
    constructor() {
        super()
    }

    override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
        const { runner } = testRunnerTelemetryPayload;
        switch (runner.options.testType) {
        case 'TestCase01' :
            return new TestCase01(this, runner)
        }
        return null;
    }
}

const worker = new WorkerTestCases();

onmessage = async function(data: any) {
    const { command, payload } = data.data;
    if (command === eIWMessageCommands.MessagePort) {
        payload.port.start();
        payload.port.addEventListener('message', (data: any) => {
            worker.ProcessMessage(data.data); // browser version
        });

        /*
        payload.port.addEventListener('messageerror', (error: any) => {
            console.error(`onmessageerror(): [${error}]`)
            worker.ProcessMessage(data.data); // browser version
        });
        */

        worker.ProcessMessage(data.data);
    } else {
        throw new Error(`Invalid command: [${command}]`)
    }
}

Mocked Factory Instance Example (for testing only)

/* eslint @typescript-eslint/no-unused-vars: 0,  @typescript-eslint/no-explicit-any: 0 */  // --> OFF
import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance } from './../index'
import { TestCase01 } from './testCase01'

import { MessagePort } from 'worker_threads';

import isNode from 'detect-node'
import { JSONObject } from '@nsshunt/stsutils';

export class WorkerTestCases extends WorkerInstance {
    #port: MessagePort | null = null;

    constructor() {
        super()
    }

    SetPort = (message: JSONObject) => {
        this.#port = message.payload.port as MessagePort;

        this.#port.on('message', (data: any) => {
            if (isNode) {
                this.ProcessMessage(data);
            } else {
                this.ProcessMessage(data.data); // browser version
            }
        });

        this.ProcessMessage(message);
    }

    override CreateAsyncRunner = (testRunnerTelemetryPayload: ITestRunnerTelemetryPayload): IRunnerInstance | null => {
        const { runner } = testRunnerTelemetryPayload;
        switch (runner.options.testType) {
        case 'TestCase01' :
            return new TestCase01(this, runner)
        }
        return null;
    }
}
1.0.143

11 months ago

1.0.142

11 months ago

1.0.145

11 months ago

1.0.144

11 months ago

1.0.141

11 months ago

1.0.140

11 months ago

1.0.147

11 months ago

1.0.146

11 months ago

1.0.149

11 months ago

1.0.148

11 months ago

1.0.62

12 months ago

1.0.61

12 months ago

1.0.60

12 months ago

1.0.66

12 months ago

1.0.65

12 months ago

1.0.64

12 months ago

1.0.63

12 months ago

1.0.69

12 months ago

1.0.68

12 months ago

1.0.67

12 months ago

1.0.132

11 months ago

1.0.131

11 months ago

1.0.134

11 months ago

1.0.133

11 months ago

1.0.130

11 months ago

1.0.139

11 months ago

1.0.136

11 months ago

1.0.135

11 months ago

1.0.138

11 months ago

1.0.137

11 months ago

1.0.73

12 months ago

1.0.72

12 months ago

1.0.71

12 months ago

1.0.70

12 months ago

1.0.77

12 months ago

1.0.76

12 months ago

1.0.75

12 months ago

1.0.74

12 months ago

1.0.79

12 months ago

1.0.78

12 months ago

1.0.164

11 months ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.161

11 months ago

1.0.160

11 months ago

1.0.163

11 months ago

1.0.162

11 months ago

1.0.40

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.154

11 months ago

1.0.153

11 months ago

1.0.156

11 months ago

1.0.155

11 months ago

1.0.49

1 year ago

1.0.150

11 months ago

1.0.152

11 months ago

1.0.151

11 months ago

1.0.158

11 months ago

1.0.157

11 months ago

1.0.159

11 months ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.59

12 months ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.101

12 months ago

1.0.100

12 months ago

1.0.107

11 months ago

1.0.106

11 months ago

1.0.109

11 months ago

1.0.108

11 months ago

1.0.103

12 months ago

1.0.102

12 months ago

1.0.105

11 months ago

1.0.104

12 months ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.121

11 months ago

1.0.120

11 months ago

1.0.123

11 months ago

1.0.122

11 months ago

1.0.129

11 months ago

1.0.128

11 months ago

1.0.125

11 months ago

1.0.124

11 months ago

1.0.127

11 months ago

1.0.126

11 months ago

1.0.80

12 months ago

1.0.84

12 months ago

1.0.83

12 months ago

1.0.82

12 months ago

1.0.81

12 months ago

1.0.88

12 months ago

1.0.87

12 months ago

1.0.86

12 months ago

1.0.85

12 months ago

1.0.89

12 months ago

1.0.110

11 months ago

1.0.112

11 months ago

1.0.111

11 months ago

1.0.118

11 months ago

1.0.117

11 months ago

1.0.119

11 months ago

1.0.114

11 months ago

1.0.113

11 months ago

1.0.116

11 months ago

1.0.115

11 months ago

1.0.91

12 months ago

1.0.90

12 months ago

1.0.95

12 months ago

1.0.94

12 months ago

1.0.93

12 months ago

1.0.92

12 months ago

1.0.99

12 months ago

1.0.98

12 months ago

1.0.97

12 months ago

1.0.96

12 months ago

1.0.22

1 year ago

1.0.23

1 year ago

1.0.21

1 year ago

1.0.19

2 years ago

1.0.20

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

0.0.23

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.10

2 years ago

0.0.22

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago