ng-apimock / core

ng-apimock core module
MIT License
34 stars 20 forks source link

Multiple mocks with same name #650

Open GrumpyMeow opened 2 years ago

GrumpyMeow commented 2 years ago

Hi,

every now and then a developer adds a new mock by cloning an existing mock-file, but forgets to change the name of the mock. (Doh!) Ngapimock does not check for this situation.

I think that having mocks with the same name is invalid in every situation and should throw an error on this. This will increase the user-experience of novice ngapimock users.

thanks!

mdasberg commented 2 years ago

@GrumpyMeow Debug information is already logged to detect duplicates.

You can enable debug logging with the following command:

export DEBUG=ng-apimock:*

This will result in a log message:

ng-apimock:processor-mock Mock with identifier '<mock name>' already exists. Overwriting existing mock.

We could introduce a configuration flag to throw an error in case there are duplicate mocks? @GrumpyMeow what do you think?

This way we don't introduce a breaking change, but provide the option to throw in case you want to.