i18next / i18next-express-middleware

[deprecated] can be replaced with i18next-http-middleware
https://github.com/i18next/i18next-http-middleware
MIT License
206 stars 52 forks source link

Error: "detectionOrder.forEach is not a function" #185

Closed TatyanaBol closed 5 years ago

TatyanaBol commented 5 years ago

Hello I'm trying to write integration tests for UI backend ( someone else wrote it, not me) In my test I run express service and make a request. It fails with an error: "detectionOrder.forEach is not a function" The error happens because in your code https://github.com/i18next/i18next-express-middleware/blob/master/src/index.js#L40 you call languageDetector.detect(req, res) and this function expects to one parameter that is null or array. This function https://github.com/i18next/i18next-browser-languageDetector/blob/9277ac25af11bafa93c0025209f12a6f4aac00b6/src/index.js#L55 fails because the parameter is not array What is wrong? Thanks in advance

jamuhl commented 5 years ago

the middleware for express comes with it's own detector - the browser one won't work on serverside -> also it get's not called on init but on every request: https://github.com/i18next/i18next-express-middleware/blob/master/src/index.js#L40

TatyanaBol commented 5 years ago

@jamuhl Thanks for your answer I'm sorry, I didn't understand what should I change? I see in debug that the call that I described happens (from i18next-express-middleware to i18next-browser-languageDetector) Is it wrong i18n configuration? Is it wrong request simulation?

It's important to note that the code works, the problem is only during tests

jamuhl commented 5 years ago

If it's on serverside it looks wrong (browserdetector)...but what do I know what you're doing...I'm not sitting next to you ;)...