Skip to content

Improve config-tests.js errors #3115

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default [
...globals.commonjs,
...globals.browser,
...globals.jasmine,
...globals.mocha,
...globals.node,
},
},
Expand Down
2 changes: 1 addition & 1 deletion overrides/android-override.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
]
},
"cohorts": [
"cohort": [
{
"name": "control",
"weight": 0
Expand Down
19 changes: 12 additions & 7 deletions tests/config-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ const previousConfigs = platformOutput.map((plat) => {
describe('Config schema tests', () => {
for (const config of latestConfigs) {
describe(`${config.name}`, () => {
before(() => {
const validate = createValidator(platformSpecificSchemas[config.name] || 'GenericV4Config');
const validateResult = validate(config.body);
if (!validateResult) {
throw new Error(
`JSON Schema validation failed:\n${formatErrors(validate.errors)} Check ${config.name} output against the schema/`,
);
}
});

// appTrackerProtection should only be on the Android config since it is a large feature
const shouldContainAppTP = config.name.split('/')[1] === 'android-config.json';
it('should contain appTrackerProtection or not', () => {
Expand All @@ -39,11 +49,6 @@ describe('Config schema tests', () => {
);
});

it('should validate against the full configV4 schema', () => {
const validate = createValidator(platformSpecificSchemas[config.name] || 'GenericV4Config');
expect(validate(config.body)).to.be.equal(true, formatErrors(validate.errors));
});

it('all features should be named correctly', () => {
const legacyFeatures = [
'androidBrowserConfig',
Expand Down Expand Up @@ -93,7 +98,7 @@ describe('Config schema tests', () => {
}
});

it('All patchSettings should also be valid', () => {
it('All patchSettings should also be valid', function () {
const validate = createValidator(platformSpecificSchemas[config.name] || 'GenericV4Config');
function applyPatchAndValidate(featureName, feature, conditionalChange, config) {
for (const change of conditionalChange) {
Expand Down Expand Up @@ -155,7 +160,7 @@ describe('Config schema tests', () => {
);
});

it('should validate against the legacy schema', () => {
it('should validate against the legacy schema', function () {
const validate = createValidator(platformSpecificSchemas[config.name] || 'LegacyConfig');
expect(validate(config.body)).to.be.equal(true, formatErrors(validate.errors));
});
Expand Down
Loading