I'm trying to get the alert to assert the text, but the problem is that when the cy.get(.alert) command is executing the alert is not visible anymore for some reason, even tho it's displayed on the page for several seconds, and after the cy.get(.alert)
The runner:
At cy.wait
At cy.get('.alert')
After cy.get('.alert')
HTML

My code:
cy.intercept('POST', Cypress.env('backdev3URL')+'/bap/one_sst_bap/create').as('createResponse')
cy.readFile('cypress/fixtures/BAPdata.json').then(BAPdata => {
cy.readFile('cypress/fixtures/PurchaseData.json').then(PurchaseData => {
cy.wait('@tableRequest')
cy.get('#subcontractors_datatable tbody').find('tr td:nth-child(1)').each((row,index) => {
if(row.text().includes("ABJ MENUISERIE")){
cy.get('#subcontractors_datatable tbody tr').eq(index).find('td:nth-child(2)').then(Nb => {
BAPdata.BAPnumber = Nb.text()
cy.writeFile('cypress/fixtures/BAPdata.json', BAPdata)
})
cy.get('#subcontractors_datatable tbody tr').eq(index).contains('button', 'BAP').click()
}
})
cy.wait('@createResponse').then(() => {
cy.get('.alert').should('contain',
'Le BAP N°'+PurchaseData.BDCid+year+month+day+' pour le sous traitant avec ID '+PurchaseData.BDCid+' a été créé avec succés')
})
var date = PurchaseData.BDCdate.split(' ')[0].replace(/\//g, ' ')
var day = date.split(' ')[0]+'1'
var month = date.split(' ')[1]
var year = date.split(' ')[2].replace(/20/, '')
const creationDate = require('dayjs')
BAPdata.BAPid = Number(BAPdata.lastBAPid)+Number(1)
BAPdata.SstBAPnumber = PurchaseData.SSTid+year+month+day
BAPdata.BAPdate = creationDate().format('DD/MM/YYYY')
cy.writeFile('cypress/fixtures/BAPdata.json', BAPdata)
})
})
Thanks!