@bitdiver/model
Advanced tools
Comparing version 1.3.8 to 1.3.9
@@ -39,4 +39,14 @@ "use strict"; | ||
this.logAdapter = opts.logAdapter ? opts.logAdapter : (0, _logadapter.getLogAdapterConsole)(); | ||
this.type = opts.type ? opts.type : STEP_TYPE_NORMAL; // creates a unique step instance id | ||
if (opts.type !== undefined) { | ||
if (opts.type === STEP_TYPE_NORMAL || opts.type === STEP_TYPE_SINGLE || opts.type === STEP_TYPE_SERVER_ONLY) { | ||
this.type = opts.type; | ||
} else { | ||
throw new Error(`The stepType '${opts.type}' is not a valid type`); | ||
} | ||
} else { | ||
this.type = STEP_TYPE_NORMAL; | ||
} // creates a unique step instance id | ||
this.stepInstanceId = uuidV4(); // A step can store information in the testcase environment. So a step could provide data | ||
@@ -51,2 +61,3 @@ // to other steps in the same testcase. For a single step or a server only step this is an | ||
// So the suite could be tested. This is important for long running tests | ||
// The mode is set by the runner | ||
@@ -103,3 +114,3 @@ this.testMode = false; // Normaly a step will only be executed if there is data defined for the testcase. | ||
run() { | ||
return this.doRun(); | ||
return Promise.resolve(); | ||
} | ||
@@ -106,0 +117,0 @@ /** |
{ | ||
"name": "@bitdiver/model", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "", | ||
@@ -39,8 +39,8 @@ "main": "lib/index.js", | ||
"@babel/cli": "7.2.3", | ||
"@babel/core": "7.3.3", | ||
"@babel/core": "7.3.4", | ||
"@babel/node": "7.2.2", | ||
"@babel/plugin-proposal-object-rest-spread": "7.3.2", | ||
"@babel/plugin-transform-runtime": "7.2.0", | ||
"@babel/plugin-proposal-object-rest-spread": "7.3.4", | ||
"@babel/plugin-transform-runtime": "7.3.4", | ||
"@babel/polyfill": "7.2.5", | ||
"@babel/preset-env": "7.3.1", | ||
"@babel/preset-env": "7.3.4", | ||
"@babel/register": "7.0.0", | ||
@@ -52,3 +52,3 @@ "babel-core": "7.0.0-bridge.0", | ||
"eslint": "5.14.1", | ||
"eslint-config-prettier": "4.0.0", | ||
"eslint-config-prettier": "4.1.0", | ||
"eslint-plugin-babel": "5.3.0", | ||
@@ -63,6 +63,6 @@ "jest": "24.1.0", | ||
"dependencies": { | ||
"@babel/runtime": "7.3.1", | ||
"@bitdiver/logadapter": "1.0.7", | ||
"@babel/runtime": "7.3.4", | ||
"@bitdiver/logadapter": "1.0.9", | ||
"uuid": "3.3.2" | ||
} | ||
} |
@@ -14,2 +14,9 @@ import { EnvironmentTestcase, STATUS_OK, STATUS_WARNING } from '../lib/index' | ||
test('EnvironmentTestcaseTest: set finish', () => { | ||
const env = new EnvironmentTestcase() | ||
expect(env.running).toEqual(true) | ||
env.finished() | ||
expect(env.running).toEqual(false) | ||
}) | ||
test('EnvironmentTestcaseTest: can not set status to better value as before.', () => { | ||
@@ -16,0 +23,0 @@ const env = new EnvironmentTestcase() |
@@ -1,2 +0,9 @@ | ||
import { StepBase, EnvironmentRun, EnvironmentTestcase } from '../lib/index' | ||
import { | ||
StepBase, | ||
EnvironmentRun, | ||
EnvironmentTestcase, | ||
STEP_TYPE_NORMAL, | ||
STEP_TYPE_SINGLE, | ||
STEP_TYPE_SERVER_ONLY, | ||
} from '../lib/index' | ||
@@ -7,2 +14,31 @@ import { getLogAdapterMemory } from '@bitdiver/logadapter' | ||
test('Logging: debug', () => { | ||
const step = getStep() | ||
step.logDebug('myDebug') | ||
expect(logAdapterMemory.logs).toEqual({ | ||
myRunId: { | ||
logs: [], | ||
testcases: { | ||
myTcName: { | ||
countAll: 12, | ||
countCurrent: 2, | ||
logs: [], | ||
steps: { | ||
myStep: { | ||
logs: [ | ||
{ | ||
countCurrent: 3, | ||
countAll: 15, | ||
data: { message: 'myDebug' }, | ||
logLevel: 'debug', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
}) | ||
test('Logging: info', () => { | ||
@@ -124,2 +160,57 @@ const step = getStep() | ||
test('Create step needData = false', () => { | ||
const step = new StepBase({ needData: false }) | ||
expect(step.needData).toEqual(false) | ||
}) | ||
test('Create step needData = undefined', () => { | ||
const step = new StepBase() | ||
expect(step.needData).toEqual(true) | ||
}) | ||
test('Create step runOnError = true', () => { | ||
const step = new StepBase({ runOnError: true }) | ||
expect(step.runOnError).toEqual(true) | ||
}) | ||
test('Create step runOnError = undefined', () => { | ||
const step = new StepBase() | ||
expect(step.runOnError).toEqual(false) | ||
}) | ||
test('Create step type = undefined', () => { | ||
const step = new StepBase() | ||
expect(step.type).toEqual('normal') | ||
}) | ||
test('Create step type = STEP_TYPE_SINGLE', () => { | ||
const step = new StepBase({ type: STEP_TYPE_SINGLE }) | ||
expect(step.type).toEqual('single') | ||
}) | ||
test('Create step type = STEP_TYPE_SERVER_ONLY', () => { | ||
const step = new StepBase({ type: STEP_TYPE_SERVER_ONLY }) | ||
expect(step.type).toEqual('serverSingle') | ||
}) | ||
test('Create step type = STEP_TYPE_NORMAL', () => { | ||
const step = new StepBase({ type: STEP_TYPE_NORMAL }) | ||
expect(step.type).toEqual('normal') | ||
}) | ||
test('Create step invalid type', () => { | ||
expect(() => { | ||
// eslint-disable-next-line no-new | ||
new StepBase({ type: 'gum' }) | ||
}).toThrow("The stepType 'gum' is not a valid type") | ||
}) | ||
test('make coverage report lucky', async () => { | ||
const step = new StepBase({ type: STEP_TYPE_NORMAL }) | ||
await step.start() | ||
await step.beforeRun() | ||
await step.run() | ||
await step.doRun() | ||
await step.afterRun() | ||
await step.end() | ||
}) | ||
function getStep() { | ||
@@ -126,0 +217,0 @@ logAdapterMemory.reset() |
@@ -11,1 +11,32 @@ import { StepRegistry, StepBase } from '../lib/index' | ||
}) | ||
test('Register to steps with the same name', () => { | ||
const registry = new StepRegistry() | ||
registry.registerStep('gumStep', StepBase) | ||
const step = registry.getStep('gumStep') | ||
expect(step.name).toEqual('gumStep') | ||
registry.registerStep('gumStep', GumStep) | ||
const step2 = registry.getStep('gumStep') | ||
expect(step2.name).toEqual('gumStep') | ||
expect(step2.myId).toEqual('otherStep') | ||
}) | ||
test('Register try to get a step which does not exists', () => { | ||
const registry = new StepRegistry() | ||
registry.registerStep('gumStep', StepBase) | ||
expect(() => { | ||
// eslint-disable-next-line no-new | ||
registry.getStep('bubu') | ||
}).toThrow("There was no step registered with the name 'bubu'") | ||
}) | ||
class GumStep extends StepBase { | ||
constructor(opts) { | ||
super(opts) | ||
this.myId = 'otherStep' | ||
} | ||
} |
42803
892
23
+ Added@babel/runtime@7.3.4(transitive)
+ Added@bitdiver/logadapter@1.0.9(transitive)
- Removed@babel/runtime@7.3.1(transitive)
- Removed@bitdiver/logadapter@1.0.7(transitive)
Updated@babel/runtime@7.3.4
Updated@bitdiver/logadapter@1.0.9