testing-library / nightwatch-testing-library Goto Github PK
View Code? Open in Web Editor NEW🦇Simple and complete custom queries for Nightwatch that encourage good testing practices.
🦇Simple and complete custom queries for Nightwatch that encourage good testing practices.
I'm trying to get it running with nightwatch and followed the examples, though I cannot get findByLabelText
to return a promise and wait for the element.
I tried it like this:
const { getQueriesFrom } = require("@testing-library/nightwatch")
describe("test", function() {
test("other", async function(browser) {
const { findByLabelText } = getQueriesFrom(browser)
browser.url("http://localhost:8080")
const input = await findByLabelText("Not Existent", { exact: false })
console.log(input)
// =>
// {
// selector: '.NWTL_findByLabelText-Not-Existent',
// nth: [Function: nth],
// browser: [Function: browser]
// }
browser.setValue(input, "[email protected]")
browser.expect.element(input).value.to.equal("[email protected]")
})
})
The problem is that awaiting findByLabelText
returns immediately and is an object with those keys selector
, nth
and browser
. It does not matter if I try with a not existent label or a label that should exist.
Then the next lines of course do not work and I get this error:
Expected element <.NWTL_findByLabelText-Not-Existent> to have value equal: "[email protected]" - element was not found - expected "equal '[email protected]'" but got: "not present" (5073ms)
and
NoSuchElementError: An error occurred while running .setValue() command on <.NWTL_findByLabelText-Not-Existent>: undefined; undefined
Shouldn't findByLabelText
wait until it either finds an input or raise an error if it cannot?
Environment:
node v12.10.0
Package.json:
"react": "^16.8.6",
"react-dom": "^16.8.6",
"@testing-library/jest-dom": "^4.2.3",
"@testing-library/nightwatch": "^1.1.0",
"geckodriver": "^1.19.1",
"nightwatch": "^1.2.4"
Error:
[E2e/Auth/Login Test] Test Suite ================================ Running: loginButtonIsVisible
window.TestingLibraryDom is undefined
Error:
{"selector":"getByText","value":["Log In"],"locatorStrategy":"getByText","name":""
at processTicksAndRejections (internal/process/task_queues.js:93:5) FAILED: 1 errors (5.117s)
Using chrome is fine but in firefox I got this error above.
Test code:
const { getQueriesFrom } = require('@testing-library/nightwatch');
module.exports = {
beforeEach(browser, done) {
browser.url('http://localhost:3000');
done();
},
// Smoke test
async loginButtonIsVisible(browser) {
const { getByText } = getQueriesFrom(browser);
browser.pause(5000);
const input = await getByText('Log In');
browser.waitForElementVisible(input, 5000);
browser.assert.visible(input);
},
};
Is nightwatch-testing-library intended to work with the testing-library's userEvent system?
I have many unit tests written with the userEvent system and I'd like to continue using the same system with nightwatch to eliminate code duplication, along with the other benefits of user-event testing.
To be more clear with code, I would like to do something like:
const input = await getByTestId('select-state')
userEvent.type(input, 'C{arrowdown}{enter}')
But type requires an Element and input
above is the following object:
{
selector: "[id='downshift-0-input']",
nth: [Function: nth],
browser: [Function: browser]
}
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch master
on remote Git repository with URL https://[secure]@github.com/testing-library/nightwatch-testing-library.git
.
Please refer to the authentication configuration documentation to configure the Git credentials on your CI environment and make sure the repositoryUrl is configured with a valid Git URL.
Good luck with your project ✨
Your semantic-release bot 📦🚀
Hello, I'm trying to set up a project with nightwatch & nightwatch-testing-library but I can't get it to work and just returns object-object for any tests.
I've followed this stackover flow article but it still results in the same issue.
Even though there is a example of a test this is against a localhost page which we can't inspect it would be good if this example was against an actual site such as Ecosia in the nightwatch example.
Could I get some help and apologies if I've posted in the wrong place.
Hello,
I would like to request an upgrade of nighwatch from v1.2.4
to version 3.
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch master
on the remote Git repository with URL https://[secure]@github.com/testing-library/nightwatch-testing-library.git
.
This can be caused by:
Good luck with your project ✨
Your semantic-release bot 📦🚀
"@testing-library/dom": "^7.26.7",
"@testing-library/nightwatch": "^2.0.0",
"@testing-library/user-event": "^12.2.2",
"chromedriver": "^87.0.0",
"nightwatch": "^1.5.1"
Node 12.19.0
Relevant code or config
const { getQueriesFrom } = require('@testing-library/nightwatch')
const { fireEvent } = require('@testing-library/dom')
module.exports = {
async 'Demo test ecosia.org'(browser) {
await browser.url('https://www.ecosia.org/')
const { getByPlaceholderText } = getQueriesFrom(browser)
const searchBox = await getByPlaceholderText(/search the web to plant trees.../i)
await browser.setValue(searchBox, 'nightwatch')
await fireEvent.submit(searchBox);
await browser.end()
}
}
What you did:
npm t -- tests/ecosiaSearchWithTL.js
What happened:
[Ecosia Search With TL] Test Suite
==================================
ℹ Connected to localhost on port 9515 (1061ms).
Using: chrome (87.0.4280.66) on Mac OS X platform.
Running: Demo test ecosia.org
FAILED: 1 errors (913ms)
Error: Unable to find the "window" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new
at Object.Demo test ecosia.org (/Users/lsr7759/projects/e2e/tests/ecosiaSearchWithTL.js:14:21)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (2.642s)
Repo:
https://github.com/lsoares/e2e-nightwatchjs-testinglibrary
Above, I tried firing an event to submit the form. It failed... but I also tried using getByRole
but it also failed for other reason. I think getByRole
would be better though.
I created this when my company was using night watch but we have since moved on to testcafe. If you are interested in taking over this project let me know and I will make you admin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.