Comments (7)
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.
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.
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.
Yes, that should work.
from cypress.
Okay thanks!
from cypress.
Agree with @troccoli, this would be a crazy useful feature.
from cypress.
Hey @jeroenvanrensen and @troccoli, it seems like this works:
cy.create(MyModel).then(myModel => console.log(myModel.some_property)
from cypress.
Related Issues (20)
- Using factories by morph name proposal
- Caching problems with `config:clear` in cypress/support/index.js
- Problems with Passport command `passport:install` does not exist HOT 2
- There are no commands defined in the "cypress" namespace. HOT 3
- Cypress 10 support HOT 5
- Laravel route "login" does not exist. HOT 6
- Typescript support HOT 2
- Global installation of Cypress HOT 3
- Issue with artisan route HOT 3
- Environment variables undefined in tests HOT 1
- Receiving error: http://localhost:8000/cypress/artisan - 419: Unknown Status Code HOT 2
- Class "App\User" not found HOT 2
- PUT requests do not work HOT 1
- laravel 9 - problem with CSRF TOKEN HOT 3
- Timeout when running `cy.refreshDatabase()` HOT 2
- Calling Login() a second time does not work HOT 1
- The wildcard for routes RegExp fails on optional parameters HOT 1
- Improve safety of environment check HOT 2
- AWS mock or stub functions
- Feature Request: Modify values using config
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress.