Skip to content

Commit 4be7b46

Browse files
authored
fix: skip is-crawlable audit when running onSuccess against DEPLOY_URL (#621)
* fix: skip crawlable audit when running onSuccess against deploy url * fix audit name * log the settings for debugging * always include the skip audit setting * try directly adding to runauditwithurl * remove outdated test * empty object * default to fullconfig, adding crawlable setting * tidy up log messages * fix spec * add new spec
1 parent b8f899e commit 4be7b46

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/lib/get-settings/get-settings.test.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import getSettings from './index.js';
22

33
describe('replacements', () => {
4-
it('should return nothing with no settings set', () => {
5-
expect(getSettings()).toEqual(undefined);
4+
it('should return the default config with no settings set', () => {
5+
const derivedSettings = getSettings();
6+
expect(derivedSettings.extends).toEqual('lighthouse:default');
7+
expect(derivedSettings.settings).toEqual({});
68
});
79

810
it('should return a template config with preset set to desktop', () => {
@@ -34,6 +36,11 @@ describe('replacements', () => {
3436
expect(derivedSettings.settings.locale).toEqual('es');
3537
});
3638

39+
it('should skip is-crawlable audit when using deployUrl', () => {
40+
const derivedSettings = getSettings({}, true);
41+
expect(derivedSettings.settings.skipAudits).toEqual(['is-crawlable']);
42+
});
43+
3744
it('should error with incorrect syntax for process.env.SETTINGS', () => {
3845
process.env.SETTINGS = 'not json';
3946
expect(getSettings).toThrow(/Invalid JSON/);

src/lib/get-settings/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ const mergeSettingsSources = (inputSettings = {}) => {
2020
return Object.assign({}, envSettings, inputSettings);
2121
};
2222

23-
const getSettings = (inputSettings) => {
23+
const getSettings = (inputSettings, isUsingDeployUrl) => {
2424
const settings = mergeSettingsSources(inputSettings);
25-
if (Object.keys(settings).length === 0) return;
2625

2726
// Set a base-level config based on the preset input value
2827
// (desktop is currently the only supported option)
@@ -35,6 +34,12 @@ const getSettings = (inputSettings) => {
3534
derivedSettings.settings.locale = settings.locale;
3635
}
3736

37+
// If we are running against the Netlify deploy URL, the injected x-robots-tag will always cause the audit to fail,
38+
// likely producing a false positive, so we skip in this case
39+
if (isUsingDeployUrl) {
40+
derivedSettings.settings.skipAudits = ['is-crawlable'];
41+
}
42+
3843
return derivedSettings;
3944
};
4045

src/lib/run-event/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const runEvent = async ({
4747
let errorMetadata = [];
4848

4949
try {
50-
const settings = getSettings(inputs?.settings);
50+
const settings = getSettings(inputs?.settings, isOnSuccess);
5151

5252
const allErrors = [];
5353
const data = [];

0 commit comments

Comments
 (0)