Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';
import EventEmitter from 'events';
import { loadYAML } from './schema/yaml/loader';
import { validateJSONSchema } from './schema/validator';
import { assertFileValidity,
import { assertFileValidity,
loadModule,
runModuleFunction,
runInlineFunction } from './utils';
Expand Down Expand Up @@ -97,7 +97,7 @@ export default class Suite extends EventEmitter {
if (!suiteFlag) {
throw new DisabledSuiteError(`Suite '${this.file}' is disabled, skipping the suite`);
}

if (data.meta.locate_files_relative === true) {
this.areFilesRelativeToSuite = true;
}
Expand Down Expand Up @@ -183,7 +183,8 @@ export default class Suite extends EventEmitter {
port: suiteConfigData.port,
scheme: suiteConfigData.scheme,
base_path: suiteConfigData.base_path,
read_timeout: suiteConfigData.read_timeout
read_timeout: suiteConfigData.read_timeout,
common_headers: suiteConfigData.common_headers,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required, because we are already reading common_headers from YAML on line#268

};

const configContext = {};
Expand Down Expand Up @@ -214,6 +215,7 @@ export default class Suite extends EventEmitter {
this.port = configuration.port;
this.base_path = configuration.base_path || '';
this.read_timeout = configuration.read_timeout || 60000;
suiteConfigData.common_headers = configuration.common_headers || [];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common_headers coming from js module should go to this.commonHeaders object, see line# 268 in master branch

} else {
this.scheme = suiteConfigData.scheme;
this.host = suiteConfigData.host;
Expand Down Expand Up @@ -419,7 +421,7 @@ export default class Suite extends EventEmitter {
let inlineResult = await runInlineFunction(inlineFunction);
loopItems = inlineResult;
} else if (loopData.dynamic.run_type === 'module') {
let modulePath = this.resolveFile(loopData.dynamic.module.module_path);
let modulePath = this.resolveFile(loopData.dynamic.module.module_path);
const module = assertFileValidity(modulePath, 'Loop data module');
const customModule = loadModule(module);

Expand All @@ -446,7 +448,7 @@ export default class Suite extends EventEmitter {
return loopItems;
}

/*
/*
options can include host, port, scheme, path_params, query_params, headers,
read_timeout, in case of body requirements ( body, form_data, form)
validateResponse option will enable/disable response validation
Expand Down Expand Up @@ -476,7 +478,7 @@ export default class Suite extends EventEmitter {
}

let opts;

if (dependencyFromSuite) {
opts = Object.assign({outerDependency: true, outerDependencySuite: dependencyFromSuite}, options);
} else {
Expand Down Expand Up @@ -507,7 +509,7 @@ export default class Suite extends EventEmitter {
}
} else if (data.run_type === 'module') {
if (data.module) {
let modulePath = this.resolveFile(data.module.module_path);
let modulePath = this.resolveFile(data.module.module_path);
const module = assertFileValidity(modulePath, 'Suite ${type} hook module');
const customModule = loadModule(module);
await runModuleFunction(customModule, data.module.function_name, _context);
Expand Down Expand Up @@ -549,4 +551,4 @@ export default class Suite extends EventEmitter {
}


}
}
6 changes: 5 additions & 1 deletion test/cli/src/modules/suite_configuration.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function syncSuiteConfig() {
this.scheme = 'http';
this.port = 3027;
this.common_headers = [{
name: 'content-type',
value: 'application/json'
}];
}

module.exports = {
syncSuiteConfig: syncSuiteConfig
};
};
19 changes: 15 additions & 4 deletions test/cli/src/suites/suite.relative.paths.suite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
meta:
name: File searching with relative paths
locate_files_relative: true
locate_files_relative: true
configuration:
host: 127.0.0.1
custom_configuration:
Expand Down Expand Up @@ -50,7 +50,7 @@ specs:
status_code: 200
json_data:
- path: $.request_content_size
value: 12371
value: 12371

- name: post non existent binary data (file) as body - should fail
request:
Expand Down Expand Up @@ -91,7 +91,7 @@ specs:
json_data:
- path: $
value:
param1: value2
param1: value2
- name: read json schema from file and validate response
request:
path: /echoJSONBodyResponse
Expand All @@ -107,4 +107,15 @@ specs:
response:
json_schema:
type: file
$ref: ./../static/schema/simple_valid.json
$ref: ./../static/schema/simple_valid.json
- name: respect suite-level common_headers from module
request:
path: /echoJSONBodyResponse
method: post
payload:
body:
type: json
content:
key: value
response:
status_code: 200
6 changes: 3 additions & 3 deletions test/cli/suite.relative.paths.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Suite with relative paths', function () {
expect(reportData.passedSuitesCount).to.equal(0);
expect(reportData.skippedSuitesCount).to.equal(0);
expect(reportData.failedSuitesCount).to.equal(1);
expect(reportData.passedTestsCount).to.equal(4);
expect(reportData.passedTestsCount).to.equal(5);
expect(reportData.skippedTestsCount).to.equal(0);
expect(reportData.failedTestsCount).to.equal(2);
expect(reportData.suites.length).to.equal(1);
Expand Down Expand Up @@ -68,6 +68,6 @@ describe('Suite with relative paths', function () {
let test = result.tests.find(t => t.name === this.test.title);
expect(test.status).to.equal('pass');
expect(test.error).to.be.a('null');
});
});

});
});