Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 6069fed

Browse files
committed
fix: throw if step type is not defined
1 parent 4684069 commit 6069fed

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/step-provider-mixin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export function StepProviderMixin(superclass) {
1515

1616
declareStep(config, ...args) {
1717
const factory = this.registeredSteps.get(config.type);
18+
if (factory === undefined) {
19+
throw new Error(`Undefined type ${config.type}`);
20+
}
21+
1822
return new factory(config, ...args);
1923
}
2024
};

tests/step-provider-mixin-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ test('provider', async t => {
2626
t.is(step.name, 's1');
2727
t.is(step.type, 'a-step');
2828
});
29+
30+
test('provider unknown type', async t => {
31+
const provider = new Provider();
32+
33+
try {
34+
const step = await provider.declareStep(
35+
{
36+
name: 's2',
37+
type: 'unknown-step'
38+
},
39+
{}
40+
);
41+
} catch (e) {
42+
t.is(e.message, 'Undefined type unknown-step');
43+
}
44+
});

0 commit comments

Comments
 (0)