Skip to content

Commit

Permalink
Merge branch 'foo'
Browse files Browse the repository at this point in the history
  • Loading branch information
BugDiver committed Jun 1, 2019
2 parents fd7c184 + a121a7f commit 24141ef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
4 changes: 3 additions & 1 deletion launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ let packageJson = `
"dependencies": {
"gauge-ts": "latest",
"ts-node": "latest",
"typescript": "latest",
"typescript": "latest"
},
"devDependencies": {
"@types/node": "latest"
}
}
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
"type": "git",
"url": "git+https://github.com/bugdiver/gauge-ts.git"
},
"keywords": ["gauge", "acceptence test", "typescript", "automaiton" ],
"keywords": [
"gauge",
"acceptence test",
"typescript",
"automaiton"
],
"author": "BugDiver <[email protected]>",
"license": "MIT",
"bugs": {
Expand Down
16 changes: 8 additions & 8 deletions src/loaders/ImplLoader.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { CodeHelper } from "../helpers/CodeHelper";
import hookRegistry from "../models/HookRegistry";
import registry from "../models/StepRegistry";
import { Util } from "../utils/Util";

export class ImplLoader extends CodeHelper {

export class ImplLoader {

public async loadImplementations() {
registry.clear();
hookRegistry.clear();
for (const file of Util.getListOfFiles()) {
process.env.STEP_FILE_PATH = file;
let c = await Util.importFile(file);
if (c.default && c.default.length == 0) {
try {
try {
if (c.default && c.default.length == 0) {
let instance = new c.default();
this.updateRegsitry(file, instance);
} catch (error) {
console.error('Failed to create a instasnce of exported class from ' + file +
`Step implemetations classes needs to exported default witout any constructor`);
}
} catch (error) {
error.message = `${error.message}. Step implemetations classes needs to be exported as default witout any constructor`
console.error(error);
}
}
}
Expand All @@ -27,4 +27,4 @@ export class ImplLoader extends CodeHelper {
registry.setInstanceForMethodsIn(file, instance);
hookRegistry.setInstanceForMethodsIn(file, instance)
}
}
}
17 changes: 16 additions & 1 deletion tests/processors/MessageProcessorFactoryTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,24 @@ describe('MessageProcessorFactory', () => {
messageType: gauge.messages.Message.MessageType.ExecutionStarting,
executionStartingRequest: new gauge.messages.ExecutionStartingRequest()
})
console.error = jest.fn();
let err = jest.spyOn(console, 'error');
await factory.process(message);
expect(err).toBeCalledTimes(0);
})

it('should load impl before loading files which fails to create instance', async () => {
Util.getListOfFiles = jest.fn().mockReturnValue(['StepImpl.ts']);
Util.importFile = jest.fn().mockResolvedValue({ default: () => { } })
let message = new gauge.messages.Message({
messageId: 0,
messageType: gauge.messages.Message.MessageType.ExecutionStarting,
executionStartingRequest: new gauge.messages.ExecutionStartingRequest()
})
console.error = jest.fn();
let err = jest.spyOn(console, 'error');
await factory.process(message);
expect(err).toHaveBeenCalled();
})

it('should process unsupport message', async () => {
Expand All @@ -51,5 +67,4 @@ describe('MessageProcessorFactory', () => {
expect(mockExit).toHaveBeenCalledWith(1);
})
})

})

0 comments on commit 24141ef

Please sign in to comment.