Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Cómo mejorar el caso de prueba que se ejecutará antes que mis otros casos de prueba en la API de Cypress

Tengo el archivo setUpDB.spec.js que es para configurar la base de datos. Necesito que este spec.js se ejecute antes que mis otros casos de prueba. ¿Puedes por favor ayudarme a resolverlo? Muchas gracias.

setUpDB.spec.js

 describe('POST method', () => { it('it is for setup data',()=> { cy.request({ method: 'POST', url:"xxxx:{ "Authorization":"LOOL", "content-type": "application/json" }, body: { "test-case": "base" }, failOnStatusCode: false }) .then((res) => { expect(res.status).to.eq(200) }) }) })`

y otro caso de prueba

 describe('POST method', () => { it('aaa', () => { cy.request({ method: 'POST', url:"https:xxxx", headers:{ "Authorization":"LOOL", "content-type": "application/json" }, body: { "id": "blabla", "bid": 10, "auctionPlatformId": "wwww", "auctionPlatformUserId": 0 }, failOnStatusCode: false }) .then((res) => { expect(res.status).to.eq(200) expect(res.body).to.have.property("id", "blabla") expect(res.body).to.have.property("price", 10) expect(res.body).to.have.property("winningBidPlatformId", "www") expect(res.body).to.have.property("winningBidPlatformUserId", 0) // assert assert.isNotNull(res.body.id, 'is not null') assert.isNotNull(res.body.createdAt, 'is not null') }) }) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¿Consideró ejecutar la solicitud de "datos de configuración" en beforeEach() ?

 beforeEach(()=> { cy.request({ method: 'POST', url:"xxxx:{ "Authorization":"LOOL", "content-type": "application/json" }, body: { "test-case": "base" }, failOnStatusCode: false }) .then((res) => { expect(res.status).to.eq(200) }) }) it('uses setup data', () => { ...

Si el procedimiento de configuración es una llamada única (no se puede repetir), intente usar un envoltorio cy.session() .

Este contenedor actúa como un caché, por lo que la solicitud interna solo se llama una vez, pero sus efectos secundarios como las cookies, localStorage se restablecen cada vez que se llama a beforeEach() .

 Cypress.config('experimentalSessionSupport', true) beforeEach(()=> { cy.session('setup-data', () => { cy.request({ method: 'POST', url:"xxxx:{ "Authorization":"LOOL", "content-type": "application/json" }, body: { "test-case": "base" }, failOnStatusCode: false }) .then((res) => { expect(res.status).to.eq(200) }) }) }) it('uses setup data', () => { ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!