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

testing: enable chai-as-promised for integ tests #27077

Merged
merged 5 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
9 changes: 8 additions & 1 deletion build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ const MINIFIED_TARGETS = [
*/
const BABELIFY_GLOBAL_TRANSFORM = {
global: true, // Transform node_modules
ignore: devDependencies(), // Ignore devDependencies
/**
* Ignore devDependencies, except for 'chai-as-promised' which contains ES6 code.
* ES6 code is fine for most test environments, but not for integration tests
* running on SauceLabs since some older browsers need ES5.
*/
ignore: devDependencies().filter(
dep => dep.indexOf('chai-as-promised') === -1
),
};

/**
Expand Down
4 changes: 2 additions & 2 deletions build-system/tasks/runtime-test/runtime-test-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function getFiles(testType) {

switch (testType) {
case 'unit':
files = testConfig.commonUnitTestPaths.concat(testConfig.chaiAsPromised);
files = testConfig.commonUnitTestPaths;
if (argv.files) {
return files.concat(argv.files);
}
Expand All @@ -147,7 +147,7 @@ function getFiles(testType) {
return files.concat(testConfig.integrationTestPaths);

case 'a4a':
return testConfig.chaiAsPromised.concat(testConfig.a4aTestPaths);
return testConfig.a4aTestPaths;

default:
throw new Error(`Test type ${testType} was not recognized`);
Expand Down
3 changes: 0 additions & 3 deletions build-system/test-configs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ const a4aTestPaths = initTestsPath.concat([
'ads/google/a4a/test/*.js',
]);

const chaiAsPromised = ['test/chai-as-promised/chai-as-promised.js'];

const unitTestPaths = [
'test/unit/**/*.js',
'ads/**/test/test-*.js',
Expand Down Expand Up @@ -204,7 +202,6 @@ const changelogIgnoreFileTypes = /\.md|\.json|\.yaml|LICENSE|CONTRIBUTORS$/;
/** @const */
module.exports = {
a4aTestPaths,
chaiAsPromised,
changelogIgnoreFileTypes,
commonIntegrationTestPaths,
commonUnitTestPaths,
Expand Down
9 changes: 2 additions & 7 deletions extensions/amp-bind/0.1/test/integration/test-bind-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,8 @@ describe
mystate: {mykey: 'myval'},
});

// Integration tests may not use chai-as-promised.
try {
await bind.getStateAsync('mystate.mykey');
expect.fail();
} catch (err) {
expect(err).match(/#mystate/);
}
const state = bind.getStateAsync('mystate.mykey');
expect(state).to.eventually.rejectedWith(/#mystate/);
samouri marked this conversation as resolved.
Show resolved Hide resolved
});

it('should not wait if the still-loading state is irrelevant', async () => {
Expand Down
2 changes: 2 additions & 0 deletions test/_init_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import PreactEnzyme from 'enzyme-adapter-preact-pure';
import sinon from /*OK*/ 'sinon';
import stringify from 'json-stable-stringify';

chai.use(require('chai-as-promised')); // eslint-disable-line
samouri marked this conversation as resolved.
Show resolved Hide resolved

// Used to print warnings for unexpected console errors.
let that;
let consoleErrorSandbox;
Expand Down
5 changes: 0 additions & 5 deletions test/chai-as-promised/.eslintrc

This file was deleted.

36 changes: 0 additions & 36 deletions test/chai-as-promised/chai-as-promised.js

This file was deleted.