Search code examples
javascripteslintsupertest

ESLint - Getting error - 'expect' is assigned a value but never used


const supertest = require('supertest-as-promised');  
const expect = require('chai').expect;  

const request = supertest(process.env.BASE_URI);`

I am getting this ESLint error:

'expect' is assigned a value but never used'

for expect statement. What changes could I make to get rid of these errors from my all .js files?


Solution

  • You are encountering the no-unused-vars rule from ESLint. You can read more about that from their documentation.

    The reason ESLint is warning about you about this is that you've declared expect and assigned a value to it.

    const expect = require('chai').expect; 
    

    However you haven't used it anywhere.

    To get rid of the error you need to use expect somewhere.

    describe('A test', () => {
      it('should do something', () => {
        expect(something).to.be.true;
      });
    });