ng-apimock icon indicating copy to clipboard operation
ng-apimock copied to clipboard

Could not select scenario [short-term]

Open mr-mateus opened this issue 8 years ago • 12 comments

[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

mr-mateus avatar Oct 30 '17 18:10 mr-mateus

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

wswebcreation avatar Oct 30 '17 20:10 wswebcreation

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 } }));
  }
};

mr-mateus avatar Oct 30 '17 22:10 mr-mateus

Hi @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.

wswebcreation avatar Oct 31 '17 05:10 wswebcreation

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 [email protected]:

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 https://github.com/mdasberg/ng-apimock/issues/29#issuecomment-340663940, or mute the thread https://github.com/notifications/unsubscribe-auth/ARhBXUqOEqHdfcSdjQ0QFHFdoAna1cVvks5sxq-sgaJpZM4QLngS .

mr-mateus avatar Oct 31 '17 09:10 mr-mateus

@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

wswebcreation avatar Oct 31 '17 10:10 wswebcreation

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 [email protected]:

@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 https://github.com/mdasberg/ng-apimock/issues/29#issuecomment-340715881, or mute the thread https://github.com/notifications/unsubscribe-auth/ARhBXYazus49T4RobHlzIBXHyADzwjoQks5sxvEcgaJpZM4QLngS .

mr-mateus avatar Oct 31 '17 15:10 mr-mateus

@mr-mateus

You are still using a different name in your script, I mean you are still using api/quoteOverview as a reference to the API. The name of the scenario shouldn't be the problem

wswebcreation avatar Oct 31 '17 19:10 wswebcreation

@wswebcreation nice catch. The expression is converted to a regular expression, hence using a / will not work

mdasberg avatar Oct 31 '17 19:10 mdasberg

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 [email protected]:

@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 https://github.com/mdasberg/ng-apimock/issues/29#issuecomment-340881536, or mute the thread https://github.com/notifications/unsubscribe-auth/ARhBXe5vH6FR6nRwG6R6eUNyDT2sVaOTks5sx3WjgaJpZM4QLngS .

mr-mateus avatar Nov 01 '17 15:11 mr-mateus

Hi @mr-mateus - I have answered this issue here: https://github.com/builtbyjay/ngapimock-test/issues/1#issuecomment-351685345

builtbyjay avatar Dec 14 '17 11:12 builtbyjay

any updates?

Zima04 avatar May 04 '19 14:05 Zima04

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 /ngapimock/* endpoints to use the correct port number.

builtbyjay avatar May 08 '19 11:05 builtbyjay