1.0.164 • Published 10 months ago

@nsshunt/stsrunnerframework v1.0.164

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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

10 months ago

1.0.142

10 months ago

1.0.145

10 months ago

1.0.144

10 months ago

1.0.141

10 months ago

1.0.140

10 months ago

1.0.147

10 months ago

1.0.146

10 months ago

1.0.149

10 months ago

1.0.148

10 months ago

1.0.62

11 months ago

1.0.61

11 months ago

1.0.60

11 months ago

1.0.66

11 months ago

1.0.65

11 months ago

1.0.64

11 months ago

1.0.63

11 months ago

1.0.69

11 months ago

1.0.68

11 months ago

1.0.67

11 months ago

1.0.132

10 months ago

1.0.131

10 months ago

1.0.134

10 months ago

1.0.133

10 months ago

1.0.130

10 months ago

1.0.139

10 months ago

1.0.136

10 months ago

1.0.135

10 months ago

1.0.138

10 months ago

1.0.137

10 months ago

1.0.73

11 months ago

1.0.72

11 months ago

1.0.71

11 months ago

1.0.70

11 months ago

1.0.77

11 months ago

1.0.76

11 months ago

1.0.75

11 months ago

1.0.74

11 months ago

1.0.79

11 months ago

1.0.78

11 months ago

1.0.164

10 months ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.161

10 months ago

1.0.160

10 months ago

1.0.163

10 months ago

1.0.162

10 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

10 months ago

1.0.153

10 months ago

1.0.156

10 months ago

1.0.155

10 months ago

1.0.49

1 year ago

1.0.150

10 months ago

1.0.152

10 months ago

1.0.151

10 months ago

1.0.158

10 months ago

1.0.157

10 months ago

1.0.159

10 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

11 months ago

1.0.58

12 months ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.101

11 months ago

1.0.100

11 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

11 months ago

1.0.102

11 months ago

1.0.105

11 months ago

1.0.104

11 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

10 months ago

1.0.128

10 months ago

1.0.125

10 months ago

1.0.124

10 months ago

1.0.127

10 months ago

1.0.126

10 months ago

1.0.80

11 months ago

1.0.84

11 months ago

1.0.83

11 months ago

1.0.82

11 months ago

1.0.81

11 months ago

1.0.88

11 months ago

1.0.87

11 months ago

1.0.86

11 months ago

1.0.85

11 months ago

1.0.89

11 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

11 months ago

1.0.90

11 months ago

1.0.95

11 months ago

1.0.94

11 months ago

1.0.93

11 months ago

1.0.92

11 months ago

1.0.99

11 months ago

1.0.98

11 months ago

1.0.97

11 months ago

1.0.96

11 months ago

1.0.22

1 year ago

1.0.23

1 year ago

1.0.21

1 year ago

1.0.19

1 year ago

1.0.20

1 year ago

1.0.18

1 year ago

1.0.17

1 year 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