cypress中严格模式下不允许使用旧的八进制文字

问题描述 投票:0回答:2

我使用cypress为POST方法编写了一个测试用例,我有一个datetime变量,如果我像datetime一样传递,并且从0开始它给我遗产八进制文字不允许编译错误。

这是测试脚本

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)
        })
    })
})
ruby-on-rails api cypress octal web-api-testing
2个回答
1
投票

它使用parseInt工作

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

0
投票

为什么不使用moment()并将变量添加到请求中?像这样的东西:

date = moment('1990-04-02', 'DDMMYYYY')
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: date })
    .then((response) => {
        expect(response.body).to.have.property('first_name', 'Jane') // true
      expect(response.status).to.eq(200)
        })
    })
})
© www.soinside.com 2019 - 2024. All rights reserved.