Open huiaic opened 7 years ago
Hi @huiaic
But when I run protractor, I'm getting this error:
What is the location of the protractor.conf.js
file and the protractor.mock.js
file? It could be that for example you have this structure
root
|_.tmp/ngApimock/protractor.mock.js
|_e2e/config/protractor.conf.js
Then the protractor.mock.js
is not in the same folder in comparison to the protractor.conf.js
. You should use a relative path, or to be sure an absolute path. That's up to you
the README says to create a separate file for each mock api call. But where should I save this file and do I need to name it something special?
When you start ng-Apimock you start it with something like this. There you will tell ng-Apimock in which folder it needs to search for the JSON files. You can create a folder structure there per API, ng-Apimock will search with a glob. So you can do it like for example this
|_authentication-api
| |_token.json
| |_bearer.json
| |_*.json
|_translation-api
|_nl.json
|_en.json
The filename of the JSON doesn't matter, I would advice you to give each JSON-file a unique name
-property, see also here so you can easily identify your files by name during tests or in your ng-Apimock UI.
I hope it helps.
I have this issue also but I have a different folder layout. I am adding this to a Angular-CLI project, everything else is fine if I write the whole path but this defeats the point. Example below;
root
|_.tmp/ngApimock/protractor.mock.js
|_protractor.conf.js
EDIT: Found my issue, in the require I was looking for mocking not ngApimock folder, thats what you get for copy and paste while watching Mock the Week.
So in protractor.conf.js I added const basePath = __dirname;
and updated the global.ngApimock
file path to;
global.ngApimock = require(basePath + '/.tmp/ngApimock/protractor.mock.js');
Having since been able to drop the basePath from the require;
global.ngApimock = require('./.tmp/ngApimock/protractor.mock.js');
I have installed ng-apimock and see that v1.4.2 is inserted into my package.json
"ng-apimock": "^1.4.2"
Added the required setup in protractor config:
But when I run protractor, I'm getting this error:
My system info:
What am I missing?
Also, I have another question - the README says to create a separate file for each mock api call. But where should I save this file and do I need to name it something special?