Giter Site home page Giter Site logo

Comments (16)

dougwilson avatar dougwilson commented on April 20, 2024

Is it possible to provide a full test app I can run to reproduce the issue? That way I can attach a debugger to see what's happening. Otherwise, you're welcome to make a PR :)

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

I will whip up a failing test.

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

Cool, also would be helpful if you provided the following version in the meantime to help me work in parallel: version of Node.js, version of express flash, version of this module.

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

Forked this project and wrote an integration test using connect-flash:

https://github.com/zbyte64/cookie-session/blob/flash-message-fail/test/flash_test.js

I think I made some mistake because I can see in the view that properly retrieves the prior flash messages but weird stuff happens when I try to send it back to the client (empty response when sending a non-empty string, 500 if I don't stringify).

The package.json of the project experiencing the issue: https://github.com/zbyte64/project-cms-backend/blob/postgres/package.json ; using node v6.4

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

I'm not seeing any issue with this module in your test, unless I'm missing something?

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

The test fails:

  1) Cookie Session with flash message should persist:

      Uncaught AssertionError: {} deepEqual { info: [ 'hello world' ] }
      + expected - actual

      -{}
      +{
      +  "info": [
      +    "hello world"
      +  ]
      +}

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

Yea, but res.body has nothing to do with this module. What if you move the assert into the server side and test what is in req.session?

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

If you can please put together a pull request with a potential fix to this module, that would probably be ideal, because I'm not sure I see any issue based on that test, but again, I may be missing something :(

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

You're right, this is an issue outside of cookie-session (connect?).

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

So to add, I had to heavily modify your test just to get it to run for me. Just cloning it, npm install + npm test gave me the following error:

$ npm test

> [email protected] test C:\cs-test\cookie-session
> mocha --check-leaks --reporter spec --bail test/



  Cookie Session with flash message
    1) should Set-Cookie


  0 passing (25ms)
  1 failing

  1) Cookie Session with flash message should Set-Cookie:
     Uncaught TypeError: Cannot read property 'header' of undefined
      at Test.<anonymous> (C:\cs-test\cookie-session\test\flash_test.js:25:21)
      at Test.assert (C:\cs-test\cookie-session\node_modules\supertest\lib\test.js:156:6)
      at Server.assert (C:\cs-test\cookie-session\node_modules\supertest\lib\test.js:127:12)
      at net.js:1277:10



npm ERR! Test failed.  See above for more details.

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

On https://github.com/jaredhanson/connect-flash I only see mentions about using it on Express 3.x. Are you sure it even works on Connect?

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

Hmm, title does mention connect at the top, but given it hasn't been updated in 4 years....
(Flash message middleware for Connect and Express.)

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

@zbyte64 does it sound like you are experiencing this bug? jaredhanson/connect-flash#22

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

Possibly, but not even error type is working for me.

from cookie-session.

dougwilson avatar dougwilson commented on April 20, 2024

Hi @zbyte64 your test you have above passes without issue if you add res.setHeader('Content-Type', 'application/json'); between lines 38 and 39. The reason your req.body was {} is because supertest didn't know it was JSON to parse without a Content-Type header.

from cookie-session.

zbyte64 avatar zbyte64 commented on April 20, 2024

Thank you.

I ended up using req-flash ( maximilianschmitt/req-flash ) and it works.

from cookie-session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.