Summer Sale! All accounts are 50% off this week.

jeroenvanrensen's avatar

Laracasts Cypress - Use the models that were just created

Hello everyone,

I'm new to Cypress and I want a test that a user can see its projects after signing in.

I tried to save the user, but this does not work:

it('can see its projects', () => {
    let user = cy.login()
    let project = cy.create('App\Models\Project', { user_id: user.id })
    cy.visit('/home').contains(project.name)
})

However, this does work:

it('can see its projects', () => {
    cy.login().then(user => {
        cy.create('App\Models\Project', { user_id: user.id }).then(project => {
            cy.visit('/home').contains(project.name)
        })
    })
})

Is the last one the only way to do this, or are there other ways to save the just created models?

0 likes
2 replies

Please or to participate in this conversation.