diff --git a/packages/cody/src/lib/hooks/behaviour-test-files/features/__feature__.feature__tmpl__ b/packages/cody/src/lib/hooks/behaviour-test-files/features/__feature__.feature__tmpl__ index 60d604ff..59b0b4f1 100644 --- a/packages/cody/src/lib/hooks/behaviour-test-files/features/__feature__.feature__tmpl__ +++ b/packages/cody/src/lib/hooks/behaviour-test-files/features/__feature__.feature__tmpl__ @@ -1,5 +1,5 @@ Feature: <%= featureNames.name %> Scenario: <%= featureNames.name %> - Given <%= givenEvent.name %> - When <%= whenEvent.name %> - Then <%= thenEvent.name %> \ No newline at end of file + Given <%= given %> + When <%= when %> + Then <%= then %> diff --git a/packages/cody/src/lib/hooks/behaviour-test-files/features/step_definitions/__feature__Steps.ts__tmpl__ b/packages/cody/src/lib/hooks/behaviour-test-files/features/step_definitions/__feature__Steps.ts__tmpl__ index 8fa9c7c9..3afaa1fb 100644 --- a/packages/cody/src/lib/hooks/behaviour-test-files/features/step_definitions/__feature__Steps.ts__tmpl__ +++ b/packages/cody/src/lib/hooks/behaviour-test-files/features/step_definitions/__feature__Steps.ts__tmpl__ @@ -23,7 +23,7 @@ class <%= feature %>Steps { this.eventStore.attachAppendToListener(listener); } - @given('<%= givenEvent.name %>') + @given('<%= given %>') public async given<%= givenEvent.className %>(): Promise { const payload = { <%- givenPayload %> @@ -47,7 +47,7 @@ class <%= feature %>Steps { } */ - @when('<%= whenEvent.name %>') + @when('<%= when %>') public async when<%= whenEvent.className %>(): Promise { const payload = { <%- whenPayload %> @@ -58,7 +58,7 @@ class <%= feature %>Steps { await this.messageBox.dispatch(command.name, command.payload, command.meta); } - @then('<%= thenEvent.name %>') + @then('<%= then %>') public async then<%= thenEvent.className %>(): Promise { const identifier = '<%= expectedIdentifier %>'; const expectedPayload = { diff --git a/packages/cody/src/lib/hooks/on-feature.ts b/packages/cody/src/lib/hooks/on-feature.ts index 14702e1a..af99c08a 100644 --- a/packages/cody/src/lib/hooks/on-feature.ts +++ b/packages/cody/src/lib/hooks/on-feature.ts @@ -11,6 +11,9 @@ import {listChangesForCodyResponse} from "./utils/fs-tree"; const modeKey = "mode"; const modeValueTest = "test-scenario"; +const givenKey = "given"; +const whenKey = "when"; +const thenKey = "then"; export const onFeature: CodyHook = async (feature: Node, ctx: Context) => { try { @@ -64,7 +67,7 @@ export const onFeature: CodyHook = async (feature: Node, ctx: Context) } } - const changesForCodyResponse = await createTestFiles(feature.getName(), givenNodes, whenCommand, thenNodes, ctx); + const changesForCodyResponse = await createTestFiles(feature.getName(), featureMeta, givenNodes, whenCommand, thenNodes, ctx); // for logging: const loggedNodes: Array = []; @@ -99,7 +102,7 @@ export const onFeature: CodyHook = async (feature: Node, ctx: Context) } } -async function createTestFiles(featureName: string, givenNodes : Array, whenCommand : Node, thenNodes : Array, ctx: Context): Promise { +async function createTestFiles(featureName: string, featureMeta: any, givenNodes : Array, whenCommand : Node, thenNodes : Array, ctx: Context): Promise { // if using a service from another board (e.g. Fleet Management), make sure to set this up in the test feature's metadata! const service = withErrorCheck(detectService, [whenCommand, ctx]); @@ -111,6 +114,9 @@ async function createTestFiles(featureName: string, givenNodes : Array, wh "feature": names(featureName).className, "serviceNames": names(service), "featureNames": names(featureName), + "given": featureMeta[givenKey], + "when": featureMeta[whenKey], + "then": featureMeta[thenKey], "givenEvent": names(givenNodes[0].getName()), "whenEvent": names(whenCommand.getName()), "thenEvent": names(thenNodes[0].getName()),