Skip to content

Commit

Permalink
refactor(aws): make buildYmlSpec generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Almouro committed Mar 5, 2024
1 parent 0e99a27 commit 4545f00
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
13 changes: 2 additions & 11 deletions packages/plugins/aws-device-farm/src/buildYmlSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,13 @@ export const buildYmlSpec = ({
android_test_host: "amazon_linux_2",
phases: {
install: {
commands: [
...Commands.INSTALL_NODE,
...Commands.UNPACKAGE_TEST_PACKAGE,
...(installCommands || []),
],
commands: [...(installCommands || [])],
},
pre_test: {
commands: [...(preTestCommands || [])],
},
test: {
commands: [
...Commands.NAVIGATE_TO_TEST_SOURCE_CODE,
...testCommands,
"mv result*.json $DEVICEFARM_LOG_DIR",
"mv *.mp4 $DEVICEFARM_LOG_DIR || true",
],
commands: [...testCommands],
},
post_test: {
commands: postTestCommands,
Expand Down
28 changes: 24 additions & 4 deletions packages/plugins/aws-device-farm/src/createTestSpecFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,38 @@ export const getSingleTestFileYml = ({
const testCode = fs.readFileSync(testFile).toString();

return buildYmlSpec({
installCommands: [...Commands.INSTALL_APPIUM],
installCommands: [
...Commands.INSTALL_NODE,
...Commands.UNPACKAGE_TEST_PACKAGE,
...Commands.INSTALL_APPIUM,
],
preTestCommands: [...Commands.START_APPIUM],
testCommands: [...Commands.createFile(testCode, "runTest.ts"), "npx ts-node runTest.ts"],
testCommands: [
...Commands.NAVIGATE_TO_TEST_SOURCE_CODE,
...Commands.createFile(testCode, "runTest.ts"),
"npx ts-node runTest.ts",
],
postTestCommands: [postTestCommand].filter(Boolean),
});
};

export const getTestCommandYml = ({ testCommand }: { testCommand: string }) => {
return buildYmlSpec({
preTestCommands: [...Commands.START_APPIUM],
installCommands: [...Commands.INSTALL_APPIUM, "npm install --global yarn"],
testCommands: ["yarn", testCommand],
installCommands: [
...Commands.INSTALL_NODE,
...Commands.UNPACKAGE_TEST_PACKAGE,
...Commands.INSTALL_APPIUM,
"npm install --global yarn",
],
testCommands: [
...Commands.NAVIGATE_TO_TEST_SOURCE_CODE,
"yarn",
testCommand,

"mv result*.json $DEVICEFARM_LOG_DIR",
"mv *.mp4 $DEVICEFARM_LOG_DIR || true",
],
});
};

Expand Down

0 comments on commit 4545f00

Please sign in to comment.