-
Notifications
You must be signed in to change notification settings - Fork 28
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lona has no browser tests #74
Comments
I will have time this week to contribute my vision on browser testing, I am going to use Cypress. We can compare / merge our approaches. |
@sobolevn Great! I am very curious how this looks in cypress. Will the tests be python or javascript code? |
TypeScript 🙂 |
I have some experience with selenium tests. I used following stack:
Regarding cypress. I believe tests should use Python because the whole library is about Python. I know there is a playwright, but I didn't use it. May be it is the best choice. It should be supported well by Microsoft. |
@sobolevn I agree with @maratori. The whole library is about using a complete web-stack from simple python scripts. Also any test infrastructure we come up with should be a reusable. For me it's not enough to test Lona, i have to test Lona based projects too. So a Python based solution would be best, but i don't want to stop you from proposing a typescript alternative 👍 |
Ok, but I guess I cannot help with that 😞
I think that I can showing some existing setups instead, this will take far less time (knowing that there's a low chance of acceptance) 🙂 So, let's have a look at examples that I / internet already have:
describe('My First Test', () => {
it('Gets, types and asserts', () => {
cy.visit('https://example.cypress.io')
cy.contains('type').click()
// Should be on a new URL which includes '/commands/actions'
cy.url().should('include', '/commands/actions')
// Get an input, type into it and verify that the value has been updated
cy.get('.action-email')
.type('fake@email.com')
.should('have.value', 'fake@email.com')
})
})
|
@sobolevn Interesting! Why do you run browser tests in docker containers? |
Because I run almost everything in a docker container 🙂 You can change browsers as easy as:
It requires the whole JVM stack. It has old sync-style API with lots of tricky parts. And it is rather slow. And the last thing about Python's bindings to Selenuim (as far as I know) they are untyped. So, any bugs won't be caught by |
@sobolevn Ah ok!
Good point! Do we have to deal with timing related issues? If i write a test with a button that turns red when clicked, how would frameworks like selenium or cypress know when the Lona client is done rendering before checking the buttons color? Do we have to add some kind of hooks into the javascript client? |
@maratori You recommended selene. Would you use it with or without pytest-selenium? |
I don't know. I guess what happens when you click a button is that some HTTP request is sent to your server. You can |
I used it without pytest-selenium. Selene uses webdriver_manager under the hood to use correct driver for your browser. Also pytest-selenium wasn't useful for me that time. About waits and timeoutsAs far as I understand all modern tools for browser testing (playwright, cypress, selene) use the same approach. Example from selene: browser.all('.srg .g') \
.should(have.size(10)) \ # wait until query returns 10 elements (default 4 seconds)
.first \
.should(have.text('Selenium automates browsers')) # wait until the first element has text (default 4 seconds) Hm... I tried to find something similar in playwright and failed :( |
@maratori: how would this look like in selene? The selene API looks very promising, but it seems to be completely sync. aiohttp testing is async out of the box |
@fscherf You are right, it is completely sync. And it was ok to me, because server didn't run in the same python process with tests. |
@maratori do you mean this library? |
@fscherf Yes |
@maratori That looks very promising! Could you prototype how we would add the playwright dependency to the test-suite so it could run in ci? I had to run |
@fscherf I can, but not very soon. I hope at the end of this week. |
@maratori I will create a pull request out of my proposal and create a simple test based on playwright |
I have setup #75 which contains a first playwright based. Overall i am pretty happy with this tool. I couldn't get pytest-playwright to run properly becaus pytest-aiohttp and pytest-playwright both try to start an ioloop in the main thread. Maybe this can be avoided by let both libraries share one ioloop, but i couldn't find out how. Also playwright is python3.7+. So we can't test 3.6. |
Hm... |
@maratori using |
@fscherf could you, please, share an example how Btw: I created an issue microsoft/playwright-pytest#74 |
@maratori Oh you are right! Running async def test_rendering(page):
await page.goto("https://example.com")
await assert page.inner_text('h1') == 'Example Domain' also raises |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
At the moment Lona has no browser tests. This means the whole Javascript client stack, which involves rendering and event handling, has no automated testing infrastructure.
I created fscherf/topic/browser-testing which contains a proposal on how to start a Lona app from the pytest infrastructure.
I personally played a little bit with selenium and would try to add selenium testing to this approach.
The text was updated successfully, but these errors were encountered: