Nervously Proposing Marriage
    Wondering what’s next for npm?Check out our public roadmap! »

    spy-on-cookies
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.0 • Public • Published

    spy-on-cookies

    A quick way to spy on document.cookie, which is more difficult than usual. If you write something that works directly with the document.cookie browser API, and you want to test it, you will need this - it's basically impossible to get configuration back out of document.cookie.

    Usage

    npm install -D spy-on-cookies

    Usage is simple - the code below shows the entire API.

    // in an example mocha test
    import spyOnCookies from 'spy-on-cookies'
    
    beforeEach(function() {
    	this.cookie = spyOnCookies()
    })
    
    afterEach(function() {
    	this.cookie.restore()
    })
    
    it('calls with the proper definition', function() {
    	document.cookie = 'test=value;domain=test.com;max-age=64000'
    	expect(this.cookie.calls).to.include('test=value;domain=test.com;max-age=64000')
    })

    Install

    npm i spy-on-cookies

    DownloadsWeekly Downloads

    4

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    3.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar