Skip to content
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

Open
mr-mateus opened this issue Oct 30, 2017 · 12 comments
Open

Could not select scenario [short-term] #29

mr-mateus opened this issue Oct 30, 2017 · 12 comments

Comments

@mr-mateus
Copy link

[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

@wswebcreation
Copy link
Collaborator

wswebcreation commented Oct 30, 2017

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

@mr-mateus
Copy link
Author

mr-mateus commented Oct 30, 2017

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

@wswebcreation
Copy link
Collaborator

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.

@mr-mateus
Copy link
Author

mr-mateus commented Oct 31, 2017 via email

@wswebcreation
Copy link
Collaborator

@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

@mr-mateus
Copy link
Author

mr-mateus commented Oct 31, 2017 via email

@wswebcreation
Copy link
Collaborator

@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

@mdasberg
Copy link
Owner

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

@mr-mateus
Copy link
Author

mr-mateus commented Nov 1, 2017 via email

@builtbyjay
Copy link

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

@Zima04
Copy link

Zima04 commented May 4, 2019

any updates?

@builtbyjay
Copy link

builtbyjay commented May 8, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants