mardi 12 février 2019

Jest test file is not reading the env variable from .env.test

describe('Testing', () => {
  it('Read ENV', () => {
    expect(process.env.REACT_APP_URL).toMatch("https://www.google.com")
  })
})

I have an .env.test file and it has the google url assigned to REACT_APP_URL:

REACT_APP_URL=https://www.google.com

When I run npm test, it shows this error

expect(string)[.not].toMatch(expected)
string value must be a string.
Received: undefined

Can someone tell me what went wrong? The .env.test is at the correct directory level because I am using .env.staging file and it is working.

Aucun commentaire:

Enregistrer un commentaire