Skip to content
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

test: Check if fixtures server is running before teardown #7006

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions e2e/fixtures/fixture-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export const startFixtureServer = async () => {

// Stop the fixture server
export const stopFixtureServer = async () => {
if (!(await isFixtureServerStarted())) {
console.log('The fixture server has already been stopped');
return;
}
await fixtureServer.stop();
console.log('The fixture server is stopped');
};
Expand All @@ -74,7 +78,6 @@ export const stopFixtureServer = async () => {
*/
export async function withFixtures(options, testSuite) {
const { fixture, restartDevice = false } = options;
let failed;
try {
// Start the fixture server
await startFixtureServer();
Expand All @@ -90,12 +93,9 @@ export async function withFixtures(options, testSuite) {

await testSuite();
} catch (error) {
failed = true;
console.error(error);
throw error;
} finally {
if (!failed) {
await stopFixtureServer();
}
await stopFixtureServer();
}
}
16 changes: 6 additions & 10 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,10 @@ export const config = {
driver.getPlatform = function getPlatform() {
return capabilities.platformName;
};
// Avoid port forwarding in Bitrise
const isRunningBitrise = process.env.BITRISE_APP_TITLE;
if (!isRunningBitrise) {
const adb = await ADB.createADB();
await adb.reversePort(8545, 8545);
await adb.reversePort(12345, 12345)
}
// Start the fixture server
await startFixtureServer();
await loadFixture();

const adb = await ADB.createADB();
await adb.reversePort(8545, 8545);
await adb.reversePort(12345, 12345)
},
/**
* Runs before a WebdriverIO command gets executed.
Expand Down Expand Up @@ -349,6 +343,8 @@ export const config = {
}

if (tags.filter((e) => e.name === FIXTURES_SKIP_ONBOARDING).length > 0) {
// Start the fixture server
await startFixtureServer();
const state = new FixtureBuilder().build();
await loadFixture({fixture: state});
}
Expand Down
2 changes: 0 additions & 2 deletions wdio/step-definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import LoginScreen from '../screen-objects/LoginScreen';
import TermOfUseScreen from '../screen-objects/Modals/TermOfUseScreen';
import WhatsNewModal from '../screen-objects/Modals/WhatsNewModal';

const fixtureServer = new FixtureServer();

Then(/^the Welcome screen is displayed$/, async () => {
await WelcomeScreen.isScreenDisplayed();
});
Expand Down
Loading