Comments (5)
from testcafe-testing-library.
Hey @benmonro thanks for your answer. But I've already include the addTestcafeTestingLibrary
call in my test I just didn't notified it in my sample 😬.
// [...]
import { addTestcafeTestingLibrary } from 'testcafe-testing-library';
import LoginPage from './model';
fixture`The login page`.beforeEach(addTestcafeTestingLibrary).page`http://localhost:3000`;
// [...]
// Error
test('should correctly handle error when a wrong password is typed', async t => {
await loginPage.login(login, 'WRONG PASSWORD');
await t.expect(loginPage.errorWrongPassword).ok();
});
// Correct
test('should correctly handle error when a wrong password is typed ', async t => {
await loginPage.login(login, 'WRONG PASSWORD');
await t.expect(loginPage.errorWrongPassword2).ok();
});
But maybe I should include it in my model. If you have an idea how to do that cause I've tried without success 😅.
import { getByTestId, getByPlaceholderText, addTestcafeTestingLibrary } from 'testcafe-testing-library';
import { t, Selector } from 'testcafe';
// I've tried here
// addTestcafeTestingLibrary()
export default class LoginPage {
constructor() {
// ... here
// addTestcafeTestingLibrary()
this.usernameInput = getByPlaceholderText(/username/i);
this.passwordInput = getByPlaceholderText(/password/i);
this.submitButton = getByTestId('submit');
this.errorIsEmpty = Selector('[data-testid="error-isEmpty"]');
// Error
this.errorWrongPassword = getByTestId('wrong-credentials');
// Correct
this.errorWrongPassword2 = Selector('[data-testid="wrong-credentials"]');
}
async login(username, password) {
// ... and here
// addTestcafeTestingLibrary()
await t
.typeText(this.usernameInput, username)
.typeText(this.passwordInput, password)
.click(this.submitButton);
}
}
Thanks 👍
from testcafe-testing-library.
from testcafe-testing-library.
@Artikodin I think I found a solution to your problem. Instead of instantiating your loginPage outside the test, try doing it in the before each like this:
let loginPage;
// eslint-disable-next-line babel/no-unused-expressions
fixture`pom`.beforeEach(async t => {
loginPage = new LoginPage();
await addTestcafeTestingLibrary(t)
})
.page`http://localhost:13370/pom.html`
let me know if that works for you.
from testcafe-testing-library.
closing due to inactivity @Artikodin feel free to reopen if it is still an issue
from testcafe-testing-library.
Related Issues (20)
- Does testcafe-testing-library support IE11 HOT 3
- add theinterned HOT 2
- testcafe useRoles are broken on 4.0.1 and 4.1.0 HOT 8
- testcafe-testing-library breaks TestCafe's testController.navigateTo function. HOT 5
- Error: TypeScript compilation failed. HOT 4
- TypeError: Cannot read property 'destUrl' of null HOT 7
- Type Error: Argument of type '{ name: string; }' is not assignable to parameter of type 'MatcherOptions'. HOT 5
- findBy/findByAll not working with within HOT 6
- Error: Cannot call method 'getByPlaceholderText' of undefined HOT 3
- Wait function not working as expected after testing-library-dom update HOT 1
- Allow configurable debug print size with DEBUG_PRINT_LIMIT env var HOT 3
- Property 'exists' does not exist on type 'NodeSnapshot'. HOT 1
- Support ClientFunctions for findByRole's name option HOT 1
- Unable to use any of the selectors from @testing-library/testcafe in testcafe tests HOT 1
- Error: Cannot call method 'queryByRole' of undefined(experimentalProxyless: true)
- FindAll, getAll, queryAll do not return arrays when used on table elements
- Text is not normalized according to testing-library's normalization documentation
- The automated release is failing 🚨
- Unpredictable assertion behaviour in highly async application HOT 6
- findByTestId doesn't work HOT 16
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 testcafe-testing-library.