Giter Site home page Giter Site logo

Comments (7)

troccoli avatar troccoli commented on May 21, 2024 2

I'm sorry about commenting on a closed issue, but I too would like to be able to use the model just created.

In my case I have a post and I want to check that the correct data is shown: title, author, date, content, etc.

Your suggestion would mean I had to specify each field I want to check

cy.create({model: 'App\\Models\\Post', attributes: {title: 'My post', content: ' My content', author: ' Giulio'}}

Apart from being very verbose, we don't use factories to their full potential. If we could get the object created it would be much clearer

const post = cy.create({model: 'App\\Models\\Post'});

cy.visit('/post/' + post.id).get('#title').should('contain', post.title);

This doesn't work, but it would be very helpful if it would.

from cypress.

jeroenvanrensen avatar jeroenvanrensen commented on May 21, 2024 1

Hello, do you mean I should do this?

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

from cypress.

JeffreyWay avatar JeffreyWay commented on May 21, 2024

No, you shouldn't need to do that in Cypress. Cypress runs commands serially. So something like this will work:

  it('shows a post', () => {
    cy.create('App\\Post', { title: 'My First Post' });

    cy.visit('/posts').contains('My First Post');
  });

If that's not working on your end, I'm not sure what to say. If you can break it down to a very simple and reproducible example, we can try to help.

from cypress.

JeffreyWay avatar JeffreyWay commented on May 21, 2024

Yes, that should work.

from cypress.

jeroenvanrensen avatar jeroenvanrensen commented on May 21, 2024

Okay thanks!

from cypress.

ShetlandJ avatar ShetlandJ commented on May 21, 2024

Agree with @troccoli, this would be a crazy useful feature.

from cypress.

ShetlandJ avatar ShetlandJ commented on May 21, 2024

Hey @jeroenvanrensen and @troccoli, it seems like this works:

cy.create(MyModel).then(myModel => console.log(myModel.some_property)

from cypress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.