mdasberg / ng-apimock

Node plugin that provides the ability to use scenario based api mocking: for local development for protractor testing
MIT License
99 stars 26 forks source link

Release 1.4.3 breaks protractor e2e tests #36

Closed builtbyjay closed 6 years ago

builtbyjay commented 6 years ago

The changes made as part of 1.4.3 are breaking my e2e tests which use ngApimock to select scenarios. https://github.com/mdasberg/ng-apimock/commit/48c99527e9a2d69d68119e81f85db85c7f9cfef9#diff-cbc5d6ec2fddf738fce80b86119065d2R57

Console output below:

> ng e2e --port 4210 --proxy-config proxy.conf.js

Process all the mocks
Register mocks
Generate the mocking web interface
Generate protractor.mock.js
** NG Live Development Server is listening on localhost:4210, open your browser on http://localhost:4210/ **
 10% building modules 3/3 modules 0 active[HPM] Proxy created: /ngapimock  ->  http://localhost:3000
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
[HPM] Proxy created: /api/v1  ->  http://localhost:3000
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
app running on port 3000
Date: 2017-12-13T18:35:07.328Z                                                          
Hash: 9363a89d3746d752f57e
Time: 12987ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 85.6 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 540 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 647 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.95 MB [initial] [rendered]
(node:90507) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[18:35:07] I/update - chromedriver: file exists /Users/jayvincent/Sites/demo-app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.34.zip
[18:35:07] I/update - chromedriver: unzipping chromedriver_2.34.zip
[18:35:07] I/update - chromedriver: setting permissions to 0755 for /Users/jayvincent/Sites/demo-app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.34
[18:35:07] I/update - chromedriver: chromedriver_2.34 up to date
[18:35:07] I/launcher - Running 1 instances of WebDriver
[18:35:07] I/direct - Using ChromeDriver directly...
Feature: demo App

  Scenario: App Loads
[HPM] GET /api/v1 -> http://localhost:3000
[18:35:10] E/launcher - Trying to load mock modules on an Angular v2+ app is not yet supported.
[18:35:11] E/launcher - Error: Trying to load mock modules on an Angular v2+ app is not yet supported.
    at process.on (/Users/jayvincent/Sites/demo-app/node_modules/protractor/lib/launcher.ts:187:50)
    at emitOne (events.js:121:20)
    at process.emit (events.js:211:7)
    at process.emit (/Users/jayvincent/Sites/demo-app/node_modules/source-map-support/source-map-support.js:439:21)
    at process._fatalException (bootstrap_node.js:374:26)
[18:35:11] E/launcher - Process exited with error code 199

I'm not quite sure I understand the logic of removing the else block for the addMockModule call. Surely the addMockModule method is always present and of type function on the Protractor browser object so it will always be called - which will result in an error being thrown for all versions of Angular 2 and above.

I'm afraid the comment Angular 2+ lacks addMockModule, but hybrid apps still need this doesn't help my understanding!

I'm using Angular 5.1.0 and Protractor 5.1.2.

mdasberg commented 6 years ago

sorry about that, I am working on a fix atm

mdasberg commented 6 years ago

I just release v1.4.4 which should fix this issue.

builtbyjay commented 6 years ago

No problem at all :)

Thank you for the quick fix @mdasberg