How to use the detox.waitFor function in detox

To help you get started, we’ve selected a few detox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RocketChat / Rocket.Chat.ReactNative / e2e / 04-createuser.spec.js View on Github external
async function navigateToRegister() {
	await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
	await element(by.id('connect-server-button')).tap();
	await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
	await element(by.id('new-server-view-input')).replaceText(data.server);
	await element(by.id('new-server-view-button')).tap();
	// we're assuming the server don't have login services and the navigation will jump to login
	await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(60000);
	await element(by.id('login-view-register')).tap();
	await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
}
github RocketChat / Rocket.Chat.ReactNative / e2e / 09-roomactions.spec.js View on Github external
it('should search and find a message', async() => {
				await element(by.id('room-actions-search')).tap();
				await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(2000);
				await expect(element(by.id('search-message-view-input'))).toBeVisible();
				await element(by.id('search-message-view-input')).replaceText(`/${ data.random }message/`);
				await waitFor(element(by.text(`${ data.random }message`).withAncestor(by.id('search-messages-view'))).atIndex(0)).toBeVisible().withTimeout(60000);
				await expect(element(by.text(`${ data.random }message`).withAncestor(by.id('search-messages-view'))).atIndex(0)).toBeVisible();
				await element(by.traits(['button'])).atIndex(0).tap();
				await backToActions();
			});
github RocketChat / Rocket.Chat.ReactNative / e2e / 10-roominfo.spec.js View on Github external
it('should change room type', async() => {
				await element(by.id('room-info-edit-view-t')).tap();
				await element(by.id('room-info-edit-view-submit')).tap();
				await waitFor(element(by.text('Settings succesfully changed!'))).toBeVisible().withTimeout(60000);
				await expect(element(by.text('Settings succesfully changed!'))).toBeVisible();
				await waitFor(element(by.text('Settings succesfully changed!'))).toBeNotVisible().withTimeout(10000);
				await expect(element(by.text('Settings succesfully changed!'))).toBeNotVisible();
				await element(by.id('room-info-edit-view-t')).tap();
				await element(by.id('room-info-edit-view-submit')).tap();
				await waitFor(element(by.text('Settings succesfully changed!'))).toBeVisible().withTimeout(60000);
				await expect(element(by.text('Settings succesfully changed!'))).toBeVisible();
				await waitFor(element(by.text('Settings succesfully changed!'))).toBeNotVisible().withTimeout(10000);
				await expect(element(by.text('Settings succesfully changed!'))).toBeNotVisible();
			});
github RocketChat / Rocket.Chat.ReactNative / e2e / 09-roomactions.spec.js View on Github external
it('should filter user', async() => {
					await waitFor(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeVisible().withTimeout(60000);
					await expect(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeVisible();
					await element(by.id('room-members-view-search')).replaceText('rocket');
					await waitFor(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeNotVisible().withTimeout(60000);
					await expect(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeNotVisible();
					await element(by.id('room-members-view-search')).tap();
					await element(by.id('room-members-view-search')).clearText('');
					await waitFor(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeVisible().withTimeout(60000);
					await expect(element(by.id(`room-members-view-item-${ data.alternateUser }`))).toBeVisible();
				});
github RocketChat / Rocket.Chat.ReactNative / e2e / 02-legal.spec.js View on Github external
it('should navigate to welcome', async() => {
			await tapBack();
			await waitFor(element(by.id('welcome-view'))).toBeVisible().withTimeout(60000);
			await expect(element(by.id('welcome-view'))).toBeVisible();
		});
github RocketChat / Rocket.Chat.ReactNative / e2e / 13-profile.spec.js View on Github external
it('should have avatar url button', async() => {
			await waitFor(element(by.id('profile-view-avatar-url-button'))).toExist().whileElement(by.id('profile-view-list')).scroll(scrollDown, 'down');
			await expect(element(by.id('profile-view-avatar-url-button'))).toExist();
		});
github RocketChat / Rocket.Chat.ReactNative / e2e / helpers / app.js View on Github external
async function logout() {
    await element(by.id('rooms-list-view-sidebar')).tap();
    await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
	await waitFor(element(by.id('sidebar-logout'))).toBeVisible().withTimeout(2000);
    await element(by.id('sidebar-logout')).tap();
    await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
    await expect(element(by.id('onboarding-view'))).toBeVisible();
}
github RocketChat / Rocket.Chat.ReactNative / e2e / helpers / app.js View on Github external
async function navigateToLogin() {
    await addServer();
    try {
        await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
        await expect(element(by.id('login-view'))).toBeVisible();
    } catch (error) {
        await waitFor(element(by.id('welcome-view'))).toBeVisible().withTimeout(2000);
        await expect(element(by.id('welcome-view'))).toBeVisible();
        await element(by.id('welcome-view-login')).tap();
        await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
        await expect(element(by.id('login-view'))).toBeVisible();
    }
}
github RocketChat / Rocket.Chat.ReactNative / e2e / 08-room.spec.js View on Github external
async function mockMessage(message) {
	await element(by.id('messagebox-input')).tap();
	await element(by.id('messagebox-input')).typeText(`${ data.random }${ message }`);
	await element(by.id('messagebox-send-message')).tap();
	await waitFor(element(by.text(`${ data.random }${ message }`))).toExist().withTimeout(60000);
};
github RocketChat / Rocket.Chat.ReactNative / e2e / helpers / app.js View on Github external
async function addServer() {
    await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
    await element(by.id('connect-server-button')).tap();
    await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
    await expect(element(by.id('new-server-view'))).toBeVisible();
    await element(by.id('new-server-view-input')).replaceText(data.server);
    await element(by.id('new-server-view-button')).tap();
}