I am trying to run my e2e tests with the ng-apimock protractor-plugin over jasmine. My actual data api, the one I am trying to mock, runs in port 8000. Whereas, my angular application runs in port 4200.
Following what explained on README files https://github.com/ng-apimock/protractor-plugin, https://github.com/ng-apimock/core and migration steps https://github.com/mdasberg/ng-apimock:
The package.json has as devDependencies:
...
"@ng-apimock/core": "^1.0.21",
"@ng-apimock/protractor-plugin": "^1.0.14"
...
and I already ran npm install.
My protractor config (protractor.conf.js) file looks like:
...
exports.config = {
...
plugins: [{package: '@ng-apimock/protractor-plugin'}],
framework: 'jasmine',
baseUrl: 'http://localhost:4200/'
...
};
My spec file (sign-in.e2e-spec.ts) looks like:
import {Client} from '@ng-apimock/base-client';
declare const ngApimock: Client;
...
describe('login', () => {
...
it('displays an error message if the signIn fails', async () => {
await ngApimock.selectScenario('login', 'wrong-credentials');
...
});
...
});
My mock file login.mock.json:
{
"name": "login",
"isArray": true,
"request": {
"url": "/login",
"method": "POST",
"body": {
"username": "^[a-zA-Z]{3,10}$",
"password": "^[a-zA-Z]{3,10}$"
}
},
"responses": {
"ok": {
"status": 200,
"default": true
},
"wrong-credentials": {
"default": false,
"status": 400
}
}
}
I am getting the following error:
Failed: An error occured while invoking http://localhost:4200/ngapimock/mocks that resulted in status code 404
I think, I have to specify the port 8000 at some point but I do not find where. I am not sure if the plugin configuration is right or not.
Aucun commentaire:
Enregistrer un commentaire