Closed y7haar closed 9 months ago
Hi @y7haar , when you enable the mock server to readArguments, it validates by default that all arguments are valid, and it throws an error in case not. So, you are probably passing a --config
argument to your command, and that produces the error.
You have some options to avoid this:
config.readArguments
option to false
. You should also disable options for reading environment vars and config file in case you neither need them.
createServer({
config: {
readArguments: false,
readEnvironment: true,
readFile: true,
},
config.allowUnknownArguments
option. This will allow you to set the server options through command arguments, but it will not throw error on unknown arguments.
createServer({
config: {
readArguments: true,
allowUnknownArguments: true,
readEnvironment: true,
readFile: true,
},
Hi @javierbrea, thanks for your quick response! Setting readArguments
to false
did the trick.
We're using mocks-server together with detox to test our react native app. The initialization of mocks-server happens inside the detox context, maybe this is why the error occurred.
Describe the bug When using the command
createServer
with a given config object, mocks server always crashes and throws the error:To Reproduce
Expected behavior Mocks Server should start and load all routes from the mocks directory as described in the docs.
Operating system, Node.js an npm versions, or browser version (please complete the following information):