I have an app created from "create-react-app", and i've added puppeteer for running end-to-end tests. While trying to run a test for logging in, I am not able to type text in the log in form inputs.
jest-puppeteer.config.js:
module.exports = {
server: {
command: `npm start`,
port: 3000,
launchTimeout: 10000,
debug: true
}
};
jest.config.js:
module.exports = {
preset: 'jest-puppeteer',
testRegex: './*\\index.test\\.js$'
};
my login test:
it('should login test user', async () => {
await page.waitForSelector('form[name="login"]');
await expect(page).toFillForm('form[name="login"]', {
username: 'abcd',
password: 'abcd'
});
await expect(page).toMatchElement('input[name="username"]', { text: 'abcd' });
}
I also tried using any of the following:
await page.type('#username', 'abcd');
await page.click('input[name="username"]');
await page.type('input[name="username"]', 'abcd');
await expect(page).toFill('input[name="username"]', 'abcd');
But still, it doesn't type any text. I wonder if my setup is suitable for create-react-app. Any idea how to solve this?