Creating-an-instance-with-pre-installed-plugins fails to start
Describe the bug
The example to create an instance taken from https://www.mocks-server.org/docs/api/javascript/#creating-an-instance-with-pre-installed-plugins (Creating an instance with pre-installed plugins and custom configuration) fails to load and throws an exception.
To Reproduce
Code example and added to a RN test module with Jest, called in the beforeAll section.
Expected behavior No exception but having a working server instance.
The Mocks-server starts without issues from the CLI with the current routes and collections.
Logs 17:13:02:70 [debug][variantHandlers] Registering 'proxy' variant handler 17:13:02:70 [debug][files] Creating files loader 'openapi' 17:13:02:70 [verbose][plugins] Registered 4 plugins without errors 17:13:02:70 [debug][variantHandlers] Registering 'json' variant handler 17:13:02:70 [debug][variantHandlers] Registering 'text' variant handler 17:13:02:70 [debug][variantHandlers] Registering 'status' variant handler 17:13:02:70 [debug][variantHandlers] Registering 'middleware' variant handler 17:13:02:70 [debug][variantHandlers] Registering 'static' variant handler 17:13:02:70 [debug][variantHandlers] Registering 'file' variant handler 17:13:02:70 [verbose][variantHandlers] Registered 6 variant handlers without errors error: unknown option '--config' ● process.exit called with "1"
at Command._exit (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:458:13)
at Command._displayError (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:1466:10)
at Command.unknownOption (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:1555:10)
at checkForUnknownOptions (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:1216:14)
at Command._parseCommand (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:1254:7)
at Command.parse (node_modules/@mocks-server/config/node_modules/commander/lib/command.js:897:10)
at CommandLineArguments.read (node_modules/@mocks-server/config/src/CommandLineArguments.js:119:13)
at Config._loadFromArgs (node_modules/@mocks-server/config/src/Config.js:113:23)
at Config._load (node_modules/@mocks-server/config/src/Config.js:165:35)
at Config.load (node_modules/@mocks-server/config/src/Config.js:187:16)
at Core._loadConfig (node_modules/@mocks-server/core/src/Core.js:154:24)
at Core.init (node_modules/@mocks-server/core/src/Core.js:199:16)
at Core.start (node_modules/@mocks-server/core/src/Core.js:209:5)`
** Operating system, Node.js an npm versions, or browser version (please complete the following information):**
- OS: MacOS 14.3.1
- Node.js: v21.6.2
- yarn: 1.22.21
- React Native: 0.73.4
Edit: I did some digging, added some logging, and it seems that the Detox/Jest environment I am in plays a role here.
~/Projects/xxxxxxx (detox_base ✗) detox test -l info -c ios.sim.debug xxxx.mock.test.js
18:47:21.842 detox[69576] B jest --config test/jest.config.js xxxx.mock.test.js
18:47:26.118 detox[69577] i xxxx.mock.test.js is assigned to 7661385B-4654-493B-9245-CEFA5FC291A3 (iPhone 15)
=> added logging in @mocks-server/config/node_modules/commander/lib/command.js/Command/_parseCommand the parameter unknown and variable parsed.unknown[0]
18:47:26.134 detox[69577] --config,test/jest.config.js,xxxx.mock.test.js (unknown)
18:47:26.134 detox[69577] i --config (parsed.unknown[0])
18:47:26:15 [debug][variantHandlers] Registering 'proxy' variant handler
..etc..
Hi @RayOei , It seems that you have the same problem described in #488. Please let me know if that solution works also in your case.
Hi @javierbrea, I missed that issue and indeed this solves the problem. I would suggest to add the option allowUnknownArguments: true more prominent to the docs as with the use of jest and detox this will happen more often, I would think. Thanks!