Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BugDiver committed Jun 1, 2019
1 parent 1b7f357 commit fd7c184
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ else if (process.argv[2] === "--start") {
+ `let runner = new GaugeRuntime();`
+ `runner.start();`
var options = `{"experimentalDecorators": true,"emitDecoratorMetadata": true}`
var runner = cp.spawn('npx', ['ts-node', '-O', options, '-e', script], {
var runner = cp.spawn('npx', ["--no-install", 'ts-node', '-O', options, '-e', script], {
env: process.env,
silent: false,
stdio: "inherit",
Expand Down
11 changes: 6 additions & 5 deletions src/loaders/ImplLoader.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { CodeHelper } from "../helpers/CodeHelper";
import hookRegistry from "../models/HookRegistry";
import registry from "../models/StepRegistry";
import { Util } from "../utils/Util";

export class ImplLoader {

export class ImplLoader extends CodeHelper {

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) { // Check if file contains Step decorator then only create a instance
if (c.default && c.default.length == 0) {
try {
let instance = new c.default();
this.updateRegsitry(file, instance);
}catch(error) {
console.error('Failed to create a instasnce of exported class from '+ file);
} catch (error) {
console.error('Failed to create a instasnce of exported class from ' + file +
`Step implemetations classes needs to exported default witout any constructor`);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/processors/MessageProcessorFactoryTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('MessageProcessorFactory', () => {
})

it('should load impl before loading files', async () => {
Util.getListOfFiles = jest.fn().mockReturnValue(['StepImpl.ts']);
class Foo {
constructor() {
}
}
Util.getListOfFiles = jest.fn().mockReturnValue(['StepImpl.ts']);
Util.importFile = jest.fn().mockResolvedValue({ default: Foo })
let message = new gauge.messages.Message({
messageId: 0,
Expand Down

0 comments on commit fd7c184

Please sign in to comment.