diff --git a/bin/script.sh b/bin/script.sh new file mode 100755 index 000000000..b546ebe1b --- /dev/null +++ b/bin/script.sh @@ -0,0 +1,2 @@ +echo "Hello, stdout!" +echo "Error occurred" >&2 \ No newline at end of file diff --git a/package.json b/package.json index 94b570e38..a2193e9d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agoric/synpress", - "version": "3.8.1-beta.0", + "version": "3.8.1-beta.1", "description": "Synpress is e2e testing framework based around Cypress.io & playwright with included MetaMask support. Test your dapps with ease.", "keywords": [ "Synpress", diff --git a/plugins/keplr-plugin.js b/plugins/keplr-plugin.js index 68a4a647a..773948701 100644 --- a/plugins/keplr-plugin.js +++ b/plugins/keplr-plugin.js @@ -1,4 +1,3 @@ -const { exec, execSync } = require('child_process'); const helpers = require('../helpers'); const playwright = require('../commands/playwright-keplr'); const keplr = require('../commands/keplr'); @@ -58,13 +57,18 @@ module.exports = (on, config) => { async execute(command) { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { - if (error) { - reject({ error, stdout, stderr }); - } else { - resolve({ stdout, stderr }); - } - }); + const { exec } = require('child_process'); + try { + exec(command, (error, stdout, stderr) => { + if (error) { + reject(error); + } else { + resolve({ stdout, stderr }); + } + }); + } catch (e) { + reject(e); + } }); }, diff --git a/synpress.config.js b/synpress.config.js index f68a6327e..56f99ca6e 100644 --- a/synpress.config.js +++ b/synpress.config.js @@ -20,6 +20,7 @@ module.exports = defineConfig({ fixturesFolder, screenshotsFolder: 'tests/e2e/screenshots', videosFolder: 'tests/e2e/videos', + bashScriptsFolder: process.cwd() +'/bin', chromeWebSecurity: true, viewportWidth: 1920, viewportHeight: 1080, diff --git a/tests/e2e/specs/keplr/keplr-spec.js b/tests/e2e/specs/keplr/keplr-spec.js index 899105be7..ed5513469 100644 --- a/tests/e2e/specs/keplr/keplr-spec.js +++ b/tests/e2e/specs/keplr/keplr-spec.js @@ -2,6 +2,7 @@ describe('Keplr', () => { context('Test commands', () => { + const scriptsFolder = Cypress.config('bashScriptsFolder'); it('Executes a command and verifies stdout and stderr', () => { const command = 'echo "Hello, stdout!" && echo "Error occurred" >&2'; @@ -12,6 +13,18 @@ describe('Keplr', () => { }); }); + it('Executes a commands from a file and verifies stdout and stderr', () => { + const fileName = 'script.sh'; + + cy.execute(`sh ${scriptsFolder}/${fileName}`).then( + ({ stdout, stderr, error }) => { + expect(stdout.trim()).to.equal('Hello, stdout!'); + expect(stderr.trim()).to.equal('Error occurred'); + expect(error).to.be.undefined; + }, + ); + }); + it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => { cy.setupWallet().then(setupFinished => { expect(setupFinished).to.be.true;