From af67c3bd12c7a5c921f3d72a9afd01e26fd0f2ca Mon Sep 17 00:00:00 2001 From: CrispusDH Date: Thu, 8 Nov 2018 00:55:48 +0200 Subject: [PATCH 1/5] Update expected_conditions_spec --- scripts/test.js | 266 ++++++++++++------------- spec/basic/expected_conditions_spec.js | 255 ++++++++++++------------ spec/basicConf.js | 3 +- spec/ciFullConf.js | 4 +- 4 files changed, 263 insertions(+), 265 deletions(-) diff --git a/scripts/test.js b/scripts/test.js index fac642b80..2f5207e65 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -5,63 +5,63 @@ var Executor = require('./test/test_util').Executor; var passingTests = [ 'node built/cli.js spec/basicConf.js', - 'node built/cli.js spec/basicConf.js --useBlockingProxy', - 'node built/cli.js spec/multiConf.js', - 'node built/cli.js spec/altRootConf.js', - 'node built/cli.js spec/inferRootConf.js', - 'node built/cli.js spec/onCleanUpAsyncReturnValueConf.js', - 'node built/cli.js spec/onCleanUpNoReturnValueConf.js', - 'node built/cli.js spec/onCleanUpSyncReturnValueConf.js', - 'node built/cli.js spec/onPrepareConf.js', - 'node built/cli.js spec/onPrepareFileConf.js', - 'node built/cli.js spec/onPreparePromiseConf.js', - 'node built/cli.js spec/onPreparePromiseFileConf.js', - 'node built/cli.js spec/mochaConf.js', - 'node built/cli.js spec/withLoginConf.js', - 'node built/cli.js spec/suitesConf.js --suite okmany', - 'node built/cli.js spec/suitesConf.js --suite okspec', - 'node built/cli.js spec/suitesConf.js --suite okmany,okspec', - 'node built/cli.js spec/plugins/smokeConf.js', - 'node built/cli.js spec/plugins/multiPluginConf.js', - 'node built/cli.js spec/plugins/jasminePostTestConf.js', - 'node built/cli.js spec/plugins/mochaPostTestConf.js', - 'node built/cli.js spec/plugins/browserGetSyncedConf.js', - 'node built/cli.js spec/plugins/browserGetUnsyncedConf.js', - 'node built/cli.js spec/plugins/waitForAngularConf.js', - 'node built/cli.js spec/interactionConf.js', - 'node built/cli.js spec/directConnectConf.js', - 'node built/cli.js spec/restartBrowserBetweenTestsConf.js', - 'node built/cli.js spec/driverProviderLocalConf.js', - 'node built/cli.js spec/driverProviderLocalConf.js --useBlockingProxy', - 'node built/cli.js spec/getCapabilitiesConf.js', - 'node built/cli.js spec/controlLockConf.js', - 'node built/cli.js spec/customFramework.js', - 'node built/cli.js spec/noGlobalsConf.js', - 'node built/cli.js spec/angular2Conf.js', - 'node built/cli.js spec/hybridConf.js', - 'node built/cli.js spec/built/noCFBasicConf.js', - 'node built/cli.js spec/built/noCFBasicConf.js --useBlockingProxy', - 'node built/cli.js spec/built/noCFPluginConf.js', - //'node scripts/driverProviderAttachSession.js', - 'node built/cli.js spec/driverProviderUseExistingWebDriver.js', - 'node built/cli.js spec/driverProviderUseExistingWebDriver.js --useBlockingProxy', - 'node scripts/errorTest.js', - // Interactive Element Explorer tasks - 'node scripts/interactive_tests/interactive_test.js', - 'node scripts/interactive_tests/with_base_url.js', - // Unit tests - 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/unit_test.json', - // Dependency tests - 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json', - // Typings tests - 'node spec/install/test.js' + // 'node built/cli.js spec/basicConf.js --useBlockingProxy', + // 'node built/cli.js spec/multiConf.js', + // 'node built/cli.js spec/altRootConf.js', + // 'node built/cli.js spec/inferRootConf.js', + // 'node built/cli.js spec/onCleanUpAsyncReturnValueConf.js', + // 'node built/cli.js spec/onCleanUpNoReturnValueConf.js', + // 'node built/cli.js spec/onCleanUpSyncReturnValueConf.js', + // 'node built/cli.js spec/onPrepareConf.js', + // 'node built/cli.js spec/onPrepareFileConf.js', + // 'node built/cli.js spec/onPreparePromiseConf.js', + // 'node built/cli.js spec/onPreparePromiseFileConf.js', + // 'node built/cli.js spec/mochaConf.js', + // 'node built/cli.js spec/withLoginConf.js', + // 'node built/cli.js spec/suitesConf.js --suite okmany', + // 'node built/cli.js spec/suitesConf.js --suite okspec', + // 'node built/cli.js spec/suitesConf.js --suite okmany,okspec', + // 'node built/cli.js spec/plugins/smokeConf.js', + // 'node built/cli.js spec/plugins/multiPluginConf.js', + // 'node built/cli.js spec/plugins/jasminePostTestConf.js', + // 'node built/cli.js spec/plugins/mochaPostTestConf.js', + // 'node built/cli.js spec/plugins/browserGetSyncedConf.js', + // 'node built/cli.js spec/plugins/browserGetUnsyncedConf.js', + // 'node built/cli.js spec/plugins/waitForAngularConf.js', + // 'node built/cli.js spec/interactionConf.js', + // 'node built/cli.js spec/directConnectConf.js', + // 'node built/cli.js spec/restartBrowserBetweenTestsConf.js', + // 'node built/cli.js spec/driverProviderLocalConf.js', + // 'node built/cli.js spec/driverProviderLocalConf.js --useBlockingProxy', + // 'node built/cli.js spec/getCapabilitiesConf.js', + // 'node built/cli.js spec/controlLockConf.js', + // 'node built/cli.js spec/customFramework.js', + // 'node built/cli.js spec/noGlobalsConf.js', + // 'node built/cli.js spec/angular2Conf.js', + // 'node built/cli.js spec/hybridConf.js', + // 'node built/cli.js spec/built/noCFBasicConf.js', + // 'node built/cli.js spec/built/noCFBasicConf.js --useBlockingProxy', + // 'node built/cli.js spec/built/noCFPluginConf.js', + // //'node scripts/driverProviderAttachSession.js', + // 'node built/cli.js spec/driverProviderUseExistingWebDriver.js', + // 'node built/cli.js spec/driverProviderUseExistingWebDriver.js --useBlockingProxy', + // 'node scripts/errorTest.js', + // // Interactive Element Explorer tasks + // 'node scripts/interactive_tests/interactive_test.js', + // 'node scripts/interactive_tests/with_base_url.js', + // // Unit tests + // 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/unit_test.json', + // // Dependency tests + // 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json', + // // Typings tests + // 'node spec/install/test.js' ]; var executor = new Executor(); passingTests.forEach(function(passing_test) { executor.addCommandlineTest(passing_test) - .assertExitCodeOnly(); + .assertExitCodeOnly(); }); /************************* @@ -69,88 +69,88 @@ passingTests.forEach(function(passing_test) { *************************/ // assert stacktrace shows line of failure -executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js') - .expectExitCode(1) - .expectErrors({ - stackTrace: 'single_failure_spec1.js:5:32' - }); - -// assert timeout works -executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js') - .expectExitCode(1) - .expectErrors({ - message: 'Timeout - Async callback was not invoked within timeout ' + - 'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.' - }) - .expectTestDuration(0, 1000); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js') - .expectExitCode(11) - .expectErrors({ - message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.' - }); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js') - .expectExitCode(1) - .expectErrors([{ - message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', - stacktrace: 'single_failure_spec1.js:5:32' - }, { - message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', - stacktrace: 'single_failure_spec2.js:5:32' - }]); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js') - .expectExitCode(1) - .expectErrors([{ - message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', - stacktrace: 'single_failure_spec1.js:5:32' - }, { - message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', - stacktrace: 'single_failure_spec2.js:5:32' - }]); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js') - .expectExitCode(1) - .expectErrors([{ - message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'', - stacktrace: 'mocha_failure_spec.js:11:20' - }]); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js') - .expectExitCode(1) - .expectErrors([ - {message: 'Expected true to be false'}, - {message: 'from setup'}, - {message: 'from postTest passing'}, - {message: 'from postTest failing'}, - {message: 'from teardown'} - ]); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js') - .expectExitCode(1) - .expectErrors([ - {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, - {message: 'The following tasks were pending:[\\s\\S]*' + - '- \\$timeout: function\\(\\) {[\\s\\S]*' + - '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' + - '*}'} - ]); - -executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' + - '--untrackOutstandingTimeouts true') - .expectExitCode(1) - .expectErrors([ - {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, - {message: 'While waiting for element with locator - ' + - 'Locator: by.binding\\(\\"slowAngularTimeoutStatus\\"\\)$'} - ]); - -executor.addCommandlineTest('node built/cli.js spec/angular2TimeoutConf.js') - .expectExitCode(1) - .expectErrors([ - {message: 'Timed out waiting for asynchronous Angular tasks to finish'}, - ]); +// executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js') +// .expectExitCode(1) +// .expectErrors({ +// stackTrace: 'single_failure_spec1.js:5:32' +// }); + +// // assert timeout works +// executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js') +// .expectExitCode(1) +// .expectErrors({ +// message: 'Timeout - Async callback was not invoked within timeout ' + +// 'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.' +// }) +// .expectTestDuration(0, 1000); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js') +// .expectExitCode(11) +// .expectErrors({ +// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.' +// }); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js') +// .expectExitCode(1) +// .expectErrors([{ +// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', +// stacktrace: 'single_failure_spec1.js:5:32' +// }, { +// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', +// stacktrace: 'single_failure_spec2.js:5:32' +// }]); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js') +// .expectExitCode(1) +// .expectErrors([{ +// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', +// stacktrace: 'single_failure_spec1.js:5:32' +// }, { +// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', +// stacktrace: 'single_failure_spec2.js:5:32' +// }]); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js') +// .expectExitCode(1) +// .expectErrors([{ +// message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'', +// stacktrace: 'mocha_failure_spec.js:11:20' +// }]); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js') +// .expectExitCode(1) +// .expectErrors([ +// {message: 'Expected true to be false'}, +// {message: 'from setup'}, +// {message: 'from postTest passing'}, +// {message: 'from postTest failing'}, +// {message: 'from teardown'} +// ]); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js') +// .expectExitCode(1) +// .expectErrors([ +// {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, +// {message: 'The following tasks were pending:[\\s\\S]*' + +// '- \\$timeout: function\\(\\) {[\\s\\S]*' + +// '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' + +// '*}'} +// ]); + +// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' + +// '--untrackOutstandingTimeouts true') +// .expectExitCode(1) +// .expectErrors([ +// {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, +// {message: 'While waiting for element with locator - ' + +// 'Locator: by.binding\\(\\"slowAngularTimeoutStatus\\"\\)$'} +// ]); + +// executor.addCommandlineTest('node built/cli.js spec/angular2TimeoutConf.js') +// .expectExitCode(1) +// .expectErrors([ +// {message: 'Timed out waiting for asynchronous Angular tasks to finish'}, +// ]); // If we're running on CircleCI, save stdout and stderr from the test run to a log file. if (process.env['CIRCLE_ARTIFACTS']) { diff --git a/spec/basic/expected_conditions_spec.js b/spec/basic/expected_conditions_spec.js index e91155070..12a3362dc 100644 --- a/spec/basic/expected_conditions_spec.js +++ b/spec/basic/expected_conditions_spec.js @@ -1,255 +1,250 @@ -var EC = protractor.ExpectedConditions; +const EC = protractor.ExpectedConditions; -describe('expected conditions', function() { - beforeEach(function() { - browser.get('index.html#/form'); +describe('expected conditions', () => { + beforeEach(async () => { + await browser.get('index.html#/form'); }); - it('should have alertIsPresent', function() { - var alertIsPresent = EC.alertIsPresent(); + it('should have alertIsPresent', async () => { + const alertIsPresent = await EC.alertIsPresent(); expect(alertIsPresent.call()).toBe(false); - var alertButton = $('#alertbutton'); - alertButton.click(); - browser.wait(protractor.ExpectedConditions.alertIsPresent(), 5000); - browser.switchTo().alert().accept(); + const alertButton = $('#alertbutton'); + await alertButton.click(); + await browser.wait(protractor.ExpectedConditions.alertIsPresent(), 5000); + await browser.switchTo().alert().accept(); }); - it('should have presenceOf', function() { - var presenceOfInvalid = EC.presenceOf($('#INVALID')); - var presenceOfHideable = EC.presenceOf($('#shower')); + it('should have presenceOf', async () => { + const presenceOfInvalid = await EC.presenceOf($('#INVALID')); + const presenceOfHideable = await EC.presenceOf($('#shower')); expect(presenceOfInvalid.call()).toBe(false); expect(presenceOfHideable.call()).toBe(true); - element(by.model('show')).click(); + await element(by.model('show')).click(); expect(presenceOfHideable.call()).toBe(true); // Should be able to reuse. }); - it('should have stalenessOf', function() { - var stalenessOfInvalid = EC.stalenessOf($('#INVALID')); - var stalenessOfHideable = EC.stalenessOf($('#shower')); + it('should have stalenessOf', async () => { + const stalenessOfInvalid = await EC.stalenessOf($('#INVALID')); + const stalenessOfHideable = await EC.stalenessOf($('#shower')); expect(stalenessOfInvalid.call()).toBe(true); expect(stalenessOfHideable.call()).toBe(false); - element(by.model('show')).click(); + await element(by.model('show')).click(); expect(stalenessOfHideable.call()).toBe(false); }); - it('should have visibilityOf', function() { - var visibilityOfInvalid = EC.visibilityOf($('#INVALID')); - var visibilityOfHideable = EC.visibilityOf($('#shower')); + it('should have visibilityOf', async () => { + const visibilityOfInvalid = await EC.visibilityOf($('#INVALID')); + const visibilityOfHideable = await EC.visibilityOf($('#shower')); expect(visibilityOfInvalid.call()).toBe(false); expect(visibilityOfHideable.call()).toBe(true); - element(by.model('show')).click(); + await element(by.model('show')).click(); expect(visibilityOfHideable.call()).toBe(false); }); - it('should have invisibilityOf', function() { - var invisibilityOfInvalid = EC.invisibilityOf($('#INVALID')); - var invisibilityOfHideable = EC.invisibilityOf($('#shower')); + it('should have invisibilityOf', async () => { + const invisibilityOfInvalid = await EC.invisibilityOf($('#INVALID')); + const invisibilityOfHideable = await EC.invisibilityOf($('#shower')); expect(invisibilityOfInvalid.call()).toBe(true); expect(invisibilityOfHideable.call()).toBe(false); - element(by.model('show')).click(); + await element(by.model('show')).click(); expect(invisibilityOfHideable.call()).toBe(true); }); - it('should have titleContains', function() { - expect(EC.titleContains('My Angular').call()).toBe(true); - expect(EC.titleContains('My AngularJS App').call()).toBe(true); + it('should have titleContains', async () => { + expect(await EC.titleContains('My Angular').call()).toBe(true); + expect(await EC.titleContains('My AngularJS App').call()).toBe(true); }); - it('should have titleIs', function() { - expect(EC.titleIs('My Angular').call()).toBe(false); - expect(EC.titleIs('My AngularJS App').call()).toBe(true); + it('should have titleIs', async () => { + expect(await EC.titleIs('My Angular').call()).toBe(false); + expect(await EC.titleIs('My AngularJS App').call()).toBe(true); }); - it('should have urlContains', function() { - var baseUrlFromSpec = browser.baseUrl; - expect(EC.urlContains('/form').call()).toBe(true); - expect(EC.urlContains(baseUrlFromSpec+ 'index.html#/form').call()).toBe(true); + it('should have urlContains', async () => { + const baseUrlFromSpec = browser.baseUrl; + expect(await EC.urlContains('/form').call()).toBe(true); + expect(await EC.urlContains(baseUrlFromSpec+ 'index.html#/form').call()).toBe(true); }); - it('should have urlIs', function() { - var baseUrlFromSpec = browser.baseUrl; - expect(EC.urlIs(browser.baseUrl).call()).toBe(false); - expect(EC.urlIs(baseUrlFromSpec+'index.html#/form').call()).toBe(true); + it('should have urlIs', async () => { + const baseUrlFromSpec = browser.baseUrl; + expect(await EC.urlIs(browser.baseUrl).call()).toBe(false); + expect(await EC.urlIs(baseUrlFromSpec+'index.html#/form').call()).toBe(true); }); - it('should have elementToBeClickable', function() { - var invalidIsClickable = EC.elementToBeClickable($('#INVALID')); - var buttonIsClickable = EC.elementToBeClickable($('#disabledButton')); + it('should have elementToBeClickable', async () => { + const invalidIsClickable = await EC.elementToBeClickable($('#INVALID')); + const buttonIsClickable = await EC.elementToBeClickable($('#disabledButton')); expect(invalidIsClickable.call()).toBe(false); expect(buttonIsClickable.call()).toBe(true); - element(by.model('disabled')).click(); + await element(by.model('disabled')).click(); expect(buttonIsClickable.call()).toBe(false); }); - it('should have textToBePresentInElement', function() { - var invalidHasText = EC.textToBePresentInElement($('#INVALID'), 'shouldnt throw'); - var hideableHasText = EC.textToBePresentInElement($('#shower'), 'Shown'); + it('should have textToBePresentInElement', async () => { + const invalidHasText = await EC.textToBePresentInElement($('#INVALID'), 'shouldnt throw'); + const hideableHasText = await EC.textToBePresentInElement($('#shower'), 'Shown'); expect(invalidHasText.call()).toBe(false); expect(hideableHasText.call()).toBe(true); - element(by.model('show')).click(); + await element(by.model('show')).click(); expect(hideableHasText.call()).toBe(false); }); - it('should have textToBePresentInElementValue', function() { - var invalid = $('#INVALID'); - var about = element(by.model('aboutbox')); + it('should have textToBePresentInElementValue', async () => { + const invalid = $('#INVALID'); + const about = element(by.model('aboutbox')); - expect(EC.textToBePresentInElementValue(invalid, 'shouldnt throw').call()).toBe(false); - expect(EC.textToBePresentInElementValue(about, 'text box').call()).toBe(true); + expect(await EC.textToBePresentInElementValue(invalid, 'shouldnt throw').call()).toBe(false); + expect(await EC.textToBePresentInElementValue(about, 'text box').call()).toBe(true); }); - it('should have elementToBeSelected', function() { - var checkbox = element(by.model('show')); + it('should have elementToBeSelected', async () => { + const checkbox = element(by.model('show')); - expect(EC.elementToBeSelected(checkbox).call()).toBe(true); - checkbox.click(); - expect(EC.elementToBeSelected(checkbox).call()).toBe(false); + expect(await EC.elementToBeSelected(checkbox).call()).toBe(true); + await checkbox.click(); + expect(await EC.elementToBeSelected(checkbox).call()).toBe(false); }); - it('should have not', function() { - var presenceOfValidElement = EC.presenceOf($('#shower')); + it('should have not', async () => { + const presenceOfValidElement = await EC.presenceOf($('#shower')); expect(presenceOfValidElement.call()).toBe(true); - expect(EC.not(presenceOfValidElement).call()).toBe(false); + expect(await EC.not(presenceOfValidElement).call()).toBe(false); }); - it('should have and', function() { - var presenceOfValidElement = EC.presenceOf($('#shower')); - var presenceOfInvalidElement = EC.presenceOf($('#INVALID')); - var validityOfTitle = EC.titleIs('My AngularJS App'); + it('should have and', async () => { + const presenceOfValidElement = await EC.presenceOf($('#shower')); + const presenceOfInvalidElement = await EC.presenceOf($('#INVALID')); + const validityOfTitle = await EC.titleIs('My AngularJS App'); - expect(EC.and(presenceOfValidElement, validityOfTitle).call()).toBe(true); + expect(await EC.and(presenceOfValidElement, validityOfTitle).call()).toBe(true); // support multiple conditions - expect(EC.and(presenceOfValidElement, - validityOfTitle, presenceOfInvalidElement).call()).toBe(false); + expect(await EC.and(presenceOfValidElement, validityOfTitle, presenceOfInvalidElement).call()).toBe(false); }); - it('and should shortcircuit', function() { - var invalidElem = $('#INVALID'); + it('and should shortcircuit', async () => { + const invalidElem = $('#INVALID'); - var presenceOfInvalidElement = EC.presenceOf(invalidElem); - var isDisplayed = invalidElem.isDisplayed.bind(invalidElem); + const presenceOfInvalidElement = await EC.presenceOf(invalidElem); + const isDisplayed = await invalidElem.isDisplayed.bind(invalidElem); // check isDisplayed on invalid element - var condition = EC.and(presenceOfInvalidElement, isDisplayed); + const condition = await EC.and(presenceOfInvalidElement, isDisplayed); // Should short circuit after the first condition is false, and not throw error expect(condition.call()).toBe(false); }); - it('should have or', function() { - var presenceOfValidElement = EC.presenceOf($('#shower')); - var presenceOfInvalidElement = EC.presenceOf($('#INVALID')); - var presenceOfInvalidElement2 = EC.presenceOf($('#INVALID2')); + it('should have or', async () => { + const presenceOfValidElement = await EC.presenceOf($('#shower')); + const presenceOfInvalidElement = await EC.presenceOf($('#INVALID')); + const presenceOfInvalidElement2 = await EC.presenceOf($('#INVALID2')); - expect(EC.or(presenceOfInvalidElement, presenceOfInvalidElement2).call()).toBe(false); + expect(await EC.or(presenceOfInvalidElement, presenceOfInvalidElement2).call()).toBe(false); // support multiple conditions - expect(EC.or(presenceOfInvalidElement, - presenceOfInvalidElement2, presenceOfValidElement).call()).toBe(true); + expect(await EC.or(presenceOfInvalidElement, presenceOfInvalidElement2, presenceOfValidElement).call()).toBe(true); }); - it('or should shortcircuit', function() { - var validElem = $('#shower'); - var invalidElem = $('#INVALID'); + it('or should shortcircuit', async () => { + const validElem = $('#shower'); + const invalidElem = $('#INVALID'); - var presenceOfValidElement = EC.presenceOf(validElem); - var isDisplayed = invalidElem.isDisplayed.bind(invalidElem); + const presenceOfValidElement = await EC.presenceOf(validElem); + const isDisplayed = await invalidElem.isDisplayed.bind(invalidElem); // check isDisplayed on invalid element - var condition = EC.or(presenceOfValidElement, isDisplayed); + const condition = await EC.or(presenceOfValidElement, isDisplayed); // Should short circuit after the first condition is true, and not throw error expect(condition.call()).toBe(true); }); - it('should be able to mix conditions', function() { - var valid = EC.presenceOf($('#shower')); - var invalid = EC.presenceOf($('#INVALID')); + it('should be able to mix conditions', async () => { + const valid = await EC.presenceOf($('#shower')); + const invalid = await EC.presenceOf($('#INVALID')); - expect(EC.or(valid, EC.and(valid, invalid)).call()).toBe(true); - expect(EC.or(EC.not(valid), EC.and(valid, invalid)).call()).toBe(false); + expect(await EC.or(valid, await EC.and(valid, invalid)).call()).toBe(true); + expect(await EC.or(await EC.not(valid), await EC.and(valid, invalid)).call()).toBe(false); }); - describe('for forked browsers', function() { + describe('for forked browsers', () => { // ensure that we can run EC on forked browser instances - it('should have alertIsPresent', function() { - var browser2 = browser.forkNewDriverInstance(); - browser2.get('index.html#/form'); - var EC2 = browser2.ExpectedConditions; - var alertIsPresent = EC2.alertIsPresent(); + it('should have alertIsPresent', async () => { + const browser2 = browser.forkNewDriverInstance(); + await browser2.get('index.html#/form'); + const EC2 = browser2.ExpectedConditions; + const alertIsPresent = await EC2.alertIsPresent(); expect(alertIsPresent.call()).toBe(false); - var alertButton = browser2.$('#alertbutton'); - alertButton.click(); - browser2.wait(EC2.alertIsPresent(), 1000); + const alertButton = browser2.$('#alertbutton'); + await alertButton.click(); + await browser2.wait(EC2.alertIsPresent(), 1000); - // TODO: Remove sleep when this is fixed: - // https://bugs.chromium.org/p/chromedriver/issues/detail?id=1500 - browser2.sleep(250); - browser2.switchTo().alert().accept(); + await browser2.switchTo().alert().accept(); }); }); - describe('race condition handling', function () { + describe('race condition handling', () => { - var disabledButton; + let disabledButton; - beforeEach(function () { + beforeEach(() => { disabledButton = $('#disabledButton[disabled="disabled"]'); }); - function enableButtonBeforeCallToUnmatchSelector(testElement, fnName) { - var originalFn = testElement[fnName]; + const enableButtonBeforeCallToUnmatchSelector = async (testElement, fnName) => { + const originalFn = testElement[fnName]; - testElement[fnName] = function () { - element(by.model('disabled')).click(); + testElement[fnName] = async () => { + await element(by.model('disabled')).click(); return originalFn.apply(this, arguments); }; // save original fn with _ prefix - testElement['_' + fnName] = originalFn; - } + testElement[`_${fnName}`] = originalFn; + }; - it('can deal with missing elements in visibilityOf', function() { - enableButtonBeforeCallToUnmatchSelector(disabledButton, 'isDisplayed'); + it('can deal with missing elements in visibilityOf', async () => { + await enableButtonBeforeCallToUnmatchSelector(disabledButton, 'isDisplayed'); - element(by.model('disabled')).click(); + await element(by.model('disabled')).click(); - expect(disabledButton._isDisplayed()).toBe(true); - expect(EC.visibilityOf(disabledButton).call()).toBe(false); + expect(await disabledButton._isDisplayed()).toBe(true); + expect(await EC.visibilityOf(disabledButton).call()).toBe(false); }); - it('can deal with missing elements in textToBePresentInElement', function() { - enableButtonBeforeCallToUnmatchSelector(disabledButton, 'getText'); + it('can deal with missing elements in textToBePresentInElement', async () => { + await enableButtonBeforeCallToUnmatchSelector(disabledButton, 'getText'); - element(by.model('disabled')).click(); + await element(by.model('disabled')).click(); expect(disabledButton._getText()).toBe('Dummy'); - expect(EC.textToBePresentInElement(disabledButton, 'Dummy').call()).toBe(false); + expect(await EC.textToBePresentInElement(disabledButton, 'Dummy').call()).toBe(false); }); - it('can deal with missing elements in textToBePresentInValue', function() { - enableButtonBeforeCallToUnmatchSelector(disabledButton, 'getAttribute'); + it('can deal with missing elements in textToBePresentInValue', async () => { + await enableButtonBeforeCallToUnmatchSelector(disabledButton, 'getAttribute'); - element(by.model('disabled')).click(); + await element(by.model('disabled')).click(); expect(disabledButton._getAttribute('value')).toBe(''); - expect(EC.textToBePresentInElementValue(disabledButton, '').call()).toBe(false); + expect(await EC.textToBePresentInElementValue(disabledButton, '').call()).toBe(false); }); - it('can deal with missing elements in elementToBeClickable', function() { - enableButtonBeforeCallToUnmatchSelector(disabledButton, 'isEnabled'); + it('can deal with missing elements in elementToBeClickable', async () => { + await enableButtonBeforeCallToUnmatchSelector(disabledButton, 'isEnabled'); - element(by.model('disabled')).click(); + await element(by.model('disabled')).click(); expect(disabledButton._isEnabled()).toBe(false); - expect(EC.elementToBeClickable(disabledButton).call()).toBe(false); + expect(await EC.elementToBeClickable(disabledButton).call()).toBe(false); }); }); }); diff --git a/spec/basicConf.js b/spec/basicConf.js index 46b451a85..cbefcb671 100644 --- a/spec/basicConf.js +++ b/spec/basicConf.js @@ -8,7 +8,8 @@ exports.config = { // Spec patterns are relative to this directory. specs: [ - 'basic/*_spec.js' + 'basic/elements_spec.js', + 'basic/expected_conditions_spec.js' ], // Exclude patterns are relative to this directory. diff --git a/spec/ciFullConf.js b/spec/ciFullConf.js index 38ec8a2d6..97f83bf02 100644 --- a/spec/ciFullConf.js +++ b/spec/ciFullConf.js @@ -8,8 +8,10 @@ exports.config = { framework: 'jasmine', // Spec patterns are relative to this directory. + // TODO(selenium4): revert back to basic/*_spec.js specs: [ - 'basic/*_spec.js' + 'basic/elements_spec.js', + 'basic/expected_conditions_spec.js' ], // Exclude patterns are relative to this directory. From 6f3505d6c23ee42744c08834b4da5562471100e3 Mon Sep 17 00:00:00 2001 From: CrispusDH Date: Thu, 8 Nov 2018 08:55:55 +0200 Subject: [PATCH 2/5] implement requested changes --- scripts/test.js | 3 +- spec/basic/expected_conditions_spec.js | 108 ++++++++++++------------- 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/scripts/test.js b/scripts/test.js index 2f5207e65..47dbd5cc9 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -60,8 +60,7 @@ var passingTests = [ var executor = new Executor(); passingTests.forEach(function(passing_test) { - executor.addCommandlineTest(passing_test) - .assertExitCodeOnly(); + executor.addCommandlineTest(passing_test).assertExitCodeOnly(); }); /************************* diff --git a/spec/basic/expected_conditions_spec.js b/spec/basic/expected_conditions_spec.js index 12a3362dc..d2c958a56 100644 --- a/spec/basic/expected_conditions_spec.js +++ b/spec/basic/expected_conditions_spec.js @@ -16,43 +16,43 @@ describe('expected conditions', () => { }); it('should have presenceOf', async () => { - const presenceOfInvalid = await EC.presenceOf($('#INVALID')); - const presenceOfHideable = await EC.presenceOf($('#shower')); + const presenceOfInvalid = EC.presenceOf($('#INVALID')); + const presenceOfHideable = EC.presenceOf($('#shower')); - expect(presenceOfInvalid.call()).toBe(false); - expect(presenceOfHideable.call()).toBe(true); + expect(await presenceOfInvalid.call()).toBe(false); + expect(await presenceOfHideable.call()).toBe(true); await element(by.model('show')).click(); - expect(presenceOfHideable.call()).toBe(true); // Should be able to reuse. + expect(await presenceOfHideable.call()).toBe(true); // Should be able to reuse. }); it('should have stalenessOf', async () => { - const stalenessOfInvalid = await EC.stalenessOf($('#INVALID')); - const stalenessOfHideable = await EC.stalenessOf($('#shower')); + const stalenessOfInvalid = EC.stalenessOf($('#INVALID')); + const stalenessOfHideable = EC.stalenessOf($('#shower')); - expect(stalenessOfInvalid.call()).toBe(true); - expect(stalenessOfHideable.call()).toBe(false); + expect(await stalenessOfInvalid.call()).toBe(true); + expect(await stalenessOfHideable.call()).toBe(false); await element(by.model('show')).click(); - expect(stalenessOfHideable.call()).toBe(false); + expect(await stalenessOfHideable.call()).toBe(false); }); it('should have visibilityOf', async () => { - const visibilityOfInvalid = await EC.visibilityOf($('#INVALID')); - const visibilityOfHideable = await EC.visibilityOf($('#shower')); + const visibilityOfInvalid = EC.visibilityOf($('#INVALID')); + const visibilityOfHideable = EC.visibilityOf($('#shower')); - expect(visibilityOfInvalid.call()).toBe(false); - expect(visibilityOfHideable.call()).toBe(true); + expect(await visibilityOfInvalid.call()).toBe(false); + expect(await visibilityOfHideable.call()).toBe(true); await element(by.model('show')).click(); - expect(visibilityOfHideable.call()).toBe(false); + expect(await visibilityOfHideable.call()).toBe(false); }); it('should have invisibilityOf', async () => { - const invisibilityOfInvalid = await EC.invisibilityOf($('#INVALID')); - const invisibilityOfHideable = await EC.invisibilityOf($('#shower')); + const invisibilityOfInvalid = EC.invisibilityOf($('#INVALID')); + const invisibilityOfHideable = EC.invisibilityOf($('#shower')); - expect(invisibilityOfInvalid.call()).toBe(true); - expect(invisibilityOfHideable.call()).toBe(false); + expect(await invisibilityOfInvalid.call()).toBe(true); + expect(await invisibilityOfHideable.call()).toBe(false); await element(by.model('show')).click(); - expect(invisibilityOfHideable.call()).toBe(true); + expect(await invisibilityOfHideable.call()).toBe(true); }); it('should have titleContains', async () => { @@ -78,23 +78,23 @@ describe('expected conditions', () => { }); it('should have elementToBeClickable', async () => { - const invalidIsClickable = await EC.elementToBeClickable($('#INVALID')); - const buttonIsClickable = await EC.elementToBeClickable($('#disabledButton')); + const invalidIsClickable = EC.elementToBeClickable($('#INVALID')); + const buttonIsClickable = EC.elementToBeClickable($('#disabledButton')); - expect(invalidIsClickable.call()).toBe(false); - expect(buttonIsClickable.call()).toBe(true); + expect(await invalidIsClickable.call()).toBe(false); + expect(await buttonIsClickable.call()).toBe(true); await element(by.model('disabled')).click(); - expect(buttonIsClickable.call()).toBe(false); + expect(await buttonIsClickable.call()).toBe(false); }); it('should have textToBePresentInElement', async () => { - const invalidHasText = await EC.textToBePresentInElement($('#INVALID'), 'shouldnt throw'); - const hideableHasText = await EC.textToBePresentInElement($('#shower'), 'Shown'); + const invalidHasText = EC.textToBePresentInElement($('#INVALID'), 'shouldnt throw'); + const hideableHasText = EC.textToBePresentInElement($('#shower'), 'Shown'); - expect(invalidHasText.call()).toBe(false); - expect(hideableHasText.call()).toBe(true); + expect(await invalidHasText.call()).toBe(false); + expect(await hideableHasText.call()).toBe(true); await element(by.model('show')).click(); - expect(hideableHasText.call()).toBe(false); + expect(await hideableHasText.call()).toBe(false); }); it('should have textToBePresentInElementValue', async () => { @@ -114,15 +114,15 @@ describe('expected conditions', () => { }); it('should have not', async () => { - const presenceOfValidElement = await EC.presenceOf($('#shower')); - expect(presenceOfValidElement.call()).toBe(true); + const presenceOfValidElement = EC.presenceOf($('#shower')); + expect(await presenceOfValidElement.call()).toBe(true); expect(await EC.not(presenceOfValidElement).call()).toBe(false); }); it('should have and', async () => { - const presenceOfValidElement = await EC.presenceOf($('#shower')); - const presenceOfInvalidElement = await EC.presenceOf($('#INVALID')); - const validityOfTitle = await EC.titleIs('My AngularJS App'); + const presenceOfValidElement = EC.presenceOf($('#shower')); + const presenceOfInvalidElement = EC.presenceOf($('#INVALID')); + const validityOfTitle = EC.titleIs('My AngularJS App'); expect(await EC.and(presenceOfValidElement, validityOfTitle).call()).toBe(true); // support multiple conditions @@ -132,20 +132,20 @@ describe('expected conditions', () => { it('and should shortcircuit', async () => { const invalidElem = $('#INVALID'); - const presenceOfInvalidElement = await EC.presenceOf(invalidElem); - const isDisplayed = await invalidElem.isDisplayed.bind(invalidElem); + const presenceOfInvalidElement = EC.presenceOf(invalidElem); + const isDisplayed = invalidElem.isDisplayed.bind(invalidElem); // check isDisplayed on invalid element - const condition = await EC.and(presenceOfInvalidElement, isDisplayed); + const condition = EC.and(presenceOfInvalidElement, isDisplayed); // Should short circuit after the first condition is false, and not throw error - expect(condition.call()).toBe(false); + expect(await condition.call()).toBe(false); }); it('should have or', async () => { - const presenceOfValidElement = await EC.presenceOf($('#shower')); - const presenceOfInvalidElement = await EC.presenceOf($('#INVALID')); - const presenceOfInvalidElement2 = await EC.presenceOf($('#INVALID2')); + const presenceOfValidElement = EC.presenceOf($('#shower')); + const presenceOfInvalidElement = EC.presenceOf($('#INVALID')); + const presenceOfInvalidElement2 = EC.presenceOf($('#INVALID2')); expect(await EC.or(presenceOfInvalidElement, presenceOfInvalidElement2).call()).toBe(false); // support multiple conditions @@ -156,22 +156,22 @@ describe('expected conditions', () => { const validElem = $('#shower'); const invalidElem = $('#INVALID'); - const presenceOfValidElement = await EC.presenceOf(validElem); - const isDisplayed = await invalidElem.isDisplayed.bind(invalidElem); + const presenceOfValidElement = EC.presenceOf(validElem); + const isDisplayed = invalidElem.isDisplayed.bind(invalidElem); // check isDisplayed on invalid element - const condition = await EC.or(presenceOfValidElement, isDisplayed); + const condition = EC.or(presenceOfValidElement, isDisplayed); // Should short circuit after the first condition is true, and not throw error - expect(condition.call()).toBe(true); + expect(await condition.call()).toBe(true); }); it('should be able to mix conditions', async () => { - const valid = await EC.presenceOf($('#shower')); - const invalid = await EC.presenceOf($('#INVALID')); + const valid = EC.presenceOf($('#shower')); + const invalid = EC.presenceOf($('#INVALID')); expect(await EC.or(valid, await EC.and(valid, invalid)).call()).toBe(true); - expect(await EC.or(await EC.not(valid), await EC.and(valid, invalid)).call()).toBe(false); + expect(await EC.or(EC.not(valid), EC.and(valid, invalid)).call()).toBe(false); }); describe('for forked browsers', () => { @@ -180,8 +180,8 @@ describe('expected conditions', () => { const browser2 = browser.forkNewDriverInstance(); await browser2.get('index.html#/form'); const EC2 = browser2.ExpectedConditions; - const alertIsPresent = await EC2.alertIsPresent(); - expect(alertIsPresent.call()).toBe(false); + const alertIsPresent = EC2.alertIsPresent(); + expect(await alertIsPresent.call()).toBe(false); const alertButton = browser2.$('#alertbutton'); await alertButton.click(); @@ -225,7 +225,7 @@ describe('expected conditions', () => { await element(by.model('disabled')).click(); - expect(disabledButton._getText()).toBe('Dummy'); + expect(await disabledButton._getText()).toBe('Dummy'); expect(await EC.textToBePresentInElement(disabledButton, 'Dummy').call()).toBe(false); }); @@ -234,7 +234,7 @@ describe('expected conditions', () => { await element(by.model('disabled')).click(); - expect(disabledButton._getAttribute('value')).toBe(''); + expect(await disabledButton._getAttribute('value')).toBe(''); expect(await EC.textToBePresentInElementValue(disabledButton, '').call()).toBe(false); }); @@ -243,7 +243,7 @@ describe('expected conditions', () => { await element(by.model('disabled')).click(); - expect(disabledButton._isEnabled()).toBe(false); + expect(await disabledButton._isEnabled()).toBe(false); expect(await EC.elementToBeClickable(disabledButton).call()).toBe(false); }); }); From e8c5278876bdff93705899bfc36a9b36d15987c1 Mon Sep 17 00:00:00 2001 From: CrispusDH Date: Thu, 8 Nov 2018 09:03:05 +0200 Subject: [PATCH 3/5] fix one more place, try to revert test.js --- scripts/test.js | 3 ++- spec/basic/expected_conditions_spec.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/test.js b/scripts/test.js index 47dbd5cc9..2f5207e65 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -60,7 +60,8 @@ var passingTests = [ var executor = new Executor(); passingTests.forEach(function(passing_test) { - executor.addCommandlineTest(passing_test).assertExitCodeOnly(); + executor.addCommandlineTest(passing_test) + .assertExitCodeOnly(); }); /************************* diff --git a/spec/basic/expected_conditions_spec.js b/spec/basic/expected_conditions_spec.js index d2c958a56..9963d7532 100644 --- a/spec/basic/expected_conditions_spec.js +++ b/spec/basic/expected_conditions_spec.js @@ -6,8 +6,8 @@ describe('expected conditions', () => { }); it('should have alertIsPresent', async () => { - const alertIsPresent = await EC.alertIsPresent(); - expect(alertIsPresent.call()).toBe(false); + const alertIsPresent = EC.alertIsPresent(); + expect(await alertIsPresent.call()).toBe(false); const alertButton = $('#alertbutton'); await alertButton.click(); From aa002a299692b564ae689b4aa38af1cc50e84cdc Mon Sep 17 00:00:00 2001 From: CrispusDH Date: Thu, 8 Nov 2018 09:04:33 +0200 Subject: [PATCH 4/5] fix after merging conflicts --- spec/basicConf.js | 2 +- spec/ciFullConf.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/basicConf.js b/spec/basicConf.js index e3bacaa79..251ebee25 100644 --- a/spec/basicConf.js +++ b/spec/basicConf.js @@ -10,7 +10,7 @@ exports.config = { // Spec patterns are relative to this directory. specs: [ 'basic/elements_spec.js', - 'basic/expected_conditions_spec.js' + 'basic/expected_conditions_spec.js', 'basic/lib_spec.js' ], diff --git a/spec/ciFullConf.js b/spec/ciFullConf.js index e66cb4afc..dd1c71e5e 100644 --- a/spec/ciFullConf.js +++ b/spec/ciFullConf.js @@ -11,7 +11,7 @@ exports.config = { // TODO(selenium4): revert back to basic/*_spec.js specs: [ 'basic/elements_spec.js', - 'basic/expected_conditions_spec.js' + 'basic/expected_conditions_spec.js', 'basic/lib_spec.js' ], From a841e5dda1c42d09396ec47dc38c2b66aa7d7e2f Mon Sep 17 00:00:00 2001 From: Craig Nishina Date: Thu, 8 Nov 2018 01:13:23 -0800 Subject: [PATCH 5/5] Removed based on weird spacing --- scripts/test.js | 160 ------------------------------------------------ 1 file changed, 160 deletions(-) delete mode 100755 scripts/test.js diff --git a/scripts/test.js b/scripts/test.js deleted file mode 100755 index 6dcf4db63..000000000 --- a/scripts/test.js +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env node -var path = require('path'); - -var Executor = require('./test/test_util').Executor; - -var passingTests = [ - 'node built/cli.js spec/basicConf.js', - // 'node built/cli.js spec/basicConf.js --useBlockingProxy', - 'node built/cli.js spec/multiConf.js', - // 'node built/cli.js spec/altRootConf.js', - // 'node built/cli.js spec/inferRootConf.js', - // 'node built/cli.js spec/onCleanUpAsyncReturnValueConf.js', - // 'node built/cli.js spec/onCleanUpNoReturnValueConf.js', - // 'node built/cli.js spec/onCleanUpSyncReturnValueConf.js', - // 'node built/cli.js spec/onPrepareConf.js', - // 'node built/cli.js spec/onPrepareFileConf.js', - // 'node built/cli.js spec/onPreparePromiseConf.js', - // 'node built/cli.js spec/onPreparePromiseFileConf.js', - // 'node built/cli.js spec/mochaConf.js', - // 'node built/cli.js spec/withLoginConf.js', - // 'node built/cli.js spec/suitesConf.js --suite okmany', - // 'node built/cli.js spec/suitesConf.js --suite okspec', - // 'node built/cli.js spec/suitesConf.js --suite okmany,okspec', - // 'node built/cli.js spec/plugins/smokeConf.js', - // 'node built/cli.js spec/plugins/multiPluginConf.js', - // 'node built/cli.js spec/plugins/jasminePostTestConf.js', - // 'node built/cli.js spec/plugins/mochaPostTestConf.js', - // 'node built/cli.js spec/plugins/browserGetSyncedConf.js', - // 'node built/cli.js spec/plugins/browserGetUnsyncedConf.js', - // 'node built/cli.js spec/plugins/waitForAngularConf.js', - // 'node built/cli.js spec/interactionConf.js', - // 'node built/cli.js spec/directConnectConf.js', - // 'node built/cli.js spec/restartBrowserBetweenTestsConf.js', - // 'node built/cli.js spec/driverProviderLocalConf.js', - // 'node built/cli.js spec/driverProviderLocalConf.js --useBlockingProxy', - // 'node built/cli.js spec/getCapabilitiesConf.js', - // 'node built/cli.js spec/controlLockConf.js', - // 'node built/cli.js spec/customFramework.js', - // 'node built/cli.js spec/noGlobalsConf.js', - // 'node built/cli.js spec/angular2Conf.js', - // 'node built/cli.js spec/hybridConf.js', - // 'node built/cli.js spec/built/noCFBasicConf.js', - // 'node built/cli.js spec/built/noCFBasicConf.js --useBlockingProxy', - // 'node built/cli.js spec/built/noCFPluginConf.js', - // //'node scripts/driverProviderAttachSession.js', - // 'node built/cli.js spec/driverProviderUseExistingWebDriver.js', - // 'node built/cli.js spec/driverProviderUseExistingWebDriver.js --useBlockingProxy', - // 'node scripts/errorTest.js', - // // Interactive Element Explorer tasks - // 'node scripts/interactive_tests/interactive_test.js', - // 'node scripts/interactive_tests/with_base_url.js', - // // Unit tests - // 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/unit_test.json', - // // Dependency tests - // 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json', - // // Typings tests - // 'node spec/install/test.js' -]; - -var executor = new Executor(); - -passingTests.forEach(function(passing_test) { - executor.addCommandlineTest(passing_test) - .assertExitCodeOnly(); -}); - -/************************* - *Below are failure tests* - *************************/ - -// assert stacktrace shows line of failure -// executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js') -// .expectExitCode(1) -// .expectErrors({ -// stackTrace: 'single_failure_spec1.js:5:32' -// }); - -// // assert timeout works -// executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js') -// .expectExitCode(1) -// .expectErrors({ -// message: 'Timeout - Async callback was not invoked within timeout ' + -// 'specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.' -// }) -// .expectTestDuration(0, 1000); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js') -// .expectExitCode(11) -// .expectErrors({ -// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.' -// }); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js') -// .expectExitCode(1) -// .expectErrors([{ -// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', -// stacktrace: 'single_failure_spec1.js:5:32' -// }, { -// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', -// stacktrace: 'single_failure_spec2.js:5:32' -// }]); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js') -// .expectExitCode(1) -// .expectErrors([{ -// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', -// stacktrace: 'single_failure_spec1.js:5:32' -// }, { -// message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', -// stacktrace: 'single_failure_spec2.js:5:32' -// }]); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js') -// .expectExitCode(1) -// .expectErrors([{ -// message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'', -// stacktrace: 'mocha_failure_spec.js:11:20' -// }]); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js') -// .expectExitCode(1) -// .expectErrors([ -// {message: 'Expected true to be false'}, -// {message: 'from setup'}, -// {message: 'from postTest passing'}, -// {message: 'from postTest failing'}, -// {message: 'from teardown'} -// ]); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js') -// .expectExitCode(1) -// .expectErrors([ -// {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, -// {message: 'The following tasks were pending:[\\s\\S]*' + -// '- \\$timeout: function\\(\\) {[\\s\\S]*' + -// '\\$scope\\.slowAngularTimeoutStatus = \'done\';[\\s\\S]' + -// '*}'} -// ]); - -// executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' + -// '--untrackOutstandingTimeouts true') -// .expectExitCode(1) -// .expectErrors([ -// {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, -// {message: 'While waiting for element with locator - ' + -// 'Locator: by.binding\\(\\"slowAngularTimeoutStatus\\"\\)$'} -// ]); - -// executor.addCommandlineTest('node built/cli.js spec/angular2TimeoutConf.js') -// .expectExitCode(1) -// .expectErrors([ -// {message: 'Timed out waiting for asynchronous Angular tasks to finish'}, -// ]); - -// If we're running on CircleCI, save stdout and stderr from the test run to a log file. -if (process.env['CIRCLE_ARTIFACTS']) { - executor.execute(path.join(process.env['CIRCLE_ARTIFACTS'], 'test_log.txt')); -} else { - executor.execute(); -}