-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not select scenario [short-term] #29
Comments
Hi @mr-mateus Can you please post your script that selects the scenario and the json file of the api you want to change? Based on the readme you should have something like in here |
Hi @wswebcreation. I have cloned the repository and followed the readme.md. spec.ts import { NgApimockTestPage } from './app.po';
import { browser } from 'protractor';
describe('ng-apimock-test App', () => {
let page: NgApimockTestPage;
let ngApimock: any = browser['ngApimock'];
beforeEach(() => {
page = new NgApimockTestPage();
});
it('should display one instalment', () => {
ngApimock.selectScenario('api/quote-overview', 'short-term');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(1);
});
it('should display three instalments', () => {
ngApimock.selectScenario('api/quote-overview', 'flexiloan-3');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(3);
});
it('should display six instalments', () => {
ngApimock.selectScenario('api/quote-overview', 'flexiloan-6');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(6);
});
it('should show an error', () => {
ngApimock.selectScenario('api/quote-overview', 'failed');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(0);
expect(page.getError()).toBeTruthy();
});
}); // Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
useAllAngular2AppRoots: true,
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
// baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
browser.ngApimock = require('./.tmp/ngApimock/protractor.mock.js');
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
}; |
Hi @mr-mateus Can you also post an example of the JSON? I'm curious about the |
Hi,
This is the scenario
short-term.json
{
"quote": {
"principal": 300,
"interest": 84.32,
"totalToRepay": 384.32,
"instalments": [{
"paymentDate": "2017-05-01",
"paymentAmount": 384.32
}],
"term": 35
}
}
quote-overview.json
{
"expression": "api/quote-overview",
"method": "GET",
"name": "api/quote-overview",
"isArray": false,
"responses": {
"short-term": {
"default": true,
"status": 200,
"headers": {
"content-type": "application/json"
},
"file": "mock_data/quote-overview/short-term.json"
},
"flexiloan-3": {
"status": 200,
"headers": {
"content-type": "application/json"
},
"file": "mock_data/quote-overview/flexiloan-3.json"
},
"flexiloan-6": {
"status": 200,
"headers": {
"content-type": "application/json"
},
"file": "mock_data/quote-overview/flexiloan-6.json"
},
"failed": {
"status": 401
}
}
}
2017-10-31 3:27 GMT-02:00 Wim Selles <notifications@github.com>:
… Hi @mr-mateus <https://github.com/mr-mateus>
Can you also post an example of the JSON? I'm curious about the name-field
of the JSON file. You now have a / in it. It could be that that is the
problem.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARhBXUqOEqHdfcSdjQ0QFHFdoAna1cVvks5sxq-sgaJpZM4QLngS>
.
|
Try camelCaseing your ngApimock.selectScenario('apiQuoteOverview', 'short-term'); That should work |
Hi,
I tried, but get the same problem...
*Could not select scenario [short-term]*
*[13:21:15] E/launcher - Error: Could not select scenario [short-term]*
* at process.on
(C:\workspace\ngapimock-test\node_modules\protractor\lib\launcher.ts:187:50)*
* at emitOne (events.js:96:13)*
* at process.emit (events.js:188:7)*
* at process.emit
(C:\workspace\ngapimock-test\node_modules\source-map-support\source-map-support.js:439:21)*
* at process._fatalException (bootstrap_node.js:296:26)*
*[13:21:15] E/launcher - Process exited with error code 199*
import { NgApimockTestPage } from './app.po';
import { browser } from 'protractor';
describe('ng-apimock-test App', () => {
let page: NgApimockTestPage;
let ngApimock: any = browser['ngApimock'];
beforeEach(() => {
page = new NgApimockTestPage();
});
it('should display one instalment', () => {
ngApimock.selectScenario('api/quoteOverview', 'short-term');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(1);
});
it('should display three instalments', () => {
ngApimock.selectScenario('api/quoteOverview', 'flexiloan-3');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(3);
});
it('should display six instalments', () => {
ngApimock.selectScenario('api/quoteOverview', 'flexiloan-6');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(6);
});
it('should show an error', () => {
ngApimock.selectScenario('api/quoteOverview', 'failed');
page.navigateTo();
expect(page.getInstalments().count()).toEqual(0);
expect(page.getError()).toBeTruthy();
});
});
2017-10-31 8:06 GMT-02:00 Wim Selles <notifications@github.com>:
… @mr-mateus <https://github.com/mr-mateus>
Try camelCaseing your name and leave out the / => "name":
"apiQuoteOverview" and then in your Protractor tests do this
ngApimock.selectScenario('apiQuoteOverview', 'short-term');
That should work
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARhBXYazus49T4RobHlzIBXHyADzwjoQks5sxvEcgaJpZM4QLngS>
.
|
You are still using a different name in your script, I mean you are still using |
@wswebcreation nice catch. The expression is converted to a regular expression, hence using a / will not work |
Hi,
I searched but didn't find the meaning of error code 199. Can you help me
to understanding?
I have two computers... one the protractor test works but the other give me
the code 199.
2017-10-31 17:31 GMT-02:00 Mischa Dasberg <notifications@github.com>:
… @wswebcreation <https://github.com/wswebcreation> nice catch. The
expression is converted to a regular expression, hence using a / will not
work
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#29 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARhBXe5vH6FR6nRwG6R6eUNyDT2sVaOTks5sx3WjgaJpZM4QLngS>
.
|
Hi @mr-mateus - I have answered this issue here: https://github.com/builtbyjay/ngapimock-test/issues/1#issuecomment-351685345 |
any updates? |
Ahh sorry, it seems I've deleted the repo referenced in the link above. From what I can remember, the cause of this error was protractor HTTP requests to ng-apimock (select scenario endpoints) using the app port number rather than the port number ng-apimock is being served from. The fix was to create a proxy rule for |
[16:06:04] E/launcher - Could not select scenario [short-term]
[16:06:04] E/launcher - Error: Could not select scenario [short-term]
at process.on (C:\workspace\ngapimock-test\node_modules\protractor\lib\launcher.ts:187:50)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at process.emit (C:\workspace\ngapimock-test\node_modules\source-map-support\source-map-support.js:439:21)
at process._fatalException (bootstrap_node.js:296:26)
[16:06:04] E/launcher - Process exited with error code 199
[16:06:04] E/launcher - Could not select scenario [short-term]
[16:06:04] E/launcher - Error: Could not select scenario [short-term]
at process.on (C:\workspace\ngapimock-test\node_modules\protractor\lib\launcher.ts:187:50)
at emitOne (events.js:96:13)
at process.emit (events.js:188:7)
at process.emit (C:\workspace\ngapimock-test\node_modules\source-map-support\source-map-support.js:439:21)
at process._fatalException (bootstrap_node.js:296:26)
[16:06:04] E/launcher - Process exited with error code 199
The text was updated successfully, but these errors were encountered: