Search code examples
ruby-on-railsapicypressoctalweb-api-testing

Legacy octal literals are not allowed in strict mode in cypress


I wrote a test case using cypress for a POST method and I've a datetime variable and if I pass like datetime and as it starts with 0 it is giving me Legacy octal literals are not allowed compiling error.

Here is the test script

describe('Create New Patient', function(){
    it('Creates new patient', function(){
        cy
        .request('POST', 'http://localhost:5002/api/v1/patients', { first_name: 'Jane', last_name: 'Dane', date_of_birth: 03041990 })
    .then((response) => {
        expect(response.body).to.have.property('first_name', 'Jane') // true
      expect(response.status).to.eq(200)
        })
    })
})

Solution

  • It worked using parseInt

      body: { first_name: 'Jane', last_name: 'Dane', date_of_birth: parseInt('19920704')}