Skip to content

Commit

Permalink
Lint for forbidden test terms in test files (#35572)
Browse files Browse the repository at this point in the history
* Lint for forbidden test terms in test files

* Fix lints

* Update build-system/test-configs/forbidden-terms.js

Co-authored-by: Raghu Simha <rsimha@amp.dev>

Co-authored-by: Raghu Simha <rsimha@amp.dev>
  • Loading branch information
jridgewell and rsimha committed Aug 9, 2021
1 parent 8d0614c commit f5c34b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions build-system/test-configs/forbidden-terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,38 @@ const forbiddenTermsGlobal = {
},
'describe\\.only': {
message: 'Please remove all instances of describe.only',
checkInTestFolder: true,
allowlist: ['testing/describes.js'],
},
'describes.*\\.only': {
message: 'Please remove all instances of describes.only',
checkInTestFolder: true,
},
'dev\\(\\)\\.assert\\(': 'Use the devAssert function instead.',
'[^.]user\\(\\)\\.assert\\(': 'Use the userAssert function instead.',
'it\\.only': '',
'it\\.only': {
message: 'Please remove all instances of it.only',
checkInTestFolder: true,
},
'Math.random[^;()]*=': 'Use Sinon to stub!!!',
'sinon\\.(spy|stub|mock)\\(': {
message: 'Use a sandbox instead to avoid repeated `#restore` calls',
checkInTestFolder: true,
},
'(\\w*([sS]py|[sS]tub|[mM]ock|clock).restore)': {
message: 'Use a sandbox instead to avoid repeated `#restore` calls',
checkInTestFolder: true,
},
'sinon\\.useFake\\w+': {
message: 'Use a sandbox instead to avoid repeated `#restore` calls',
checkInTestFolder: true,
},
'sandbox\\.(spy|stub|mock)\\([^,\\s]*[iI]?frame[^,\\s]*,': {
message:
'Do NOT stub on a cross domain iframe! #5359\n' +
' If this is same domain, mark /*OK*/.\n' +
' If this is cross domain, overwrite the method directly.',
checkInTestFolder: true,
},
'window\\.sandbox': {
message: 'Usage of window.sandbox is forbidden. Use env.sandbox instead.',
Expand Down Expand Up @@ -511,7 +520,10 @@ const forbiddenTermsGlobal = {
'src/service/url-replacements-impl.js',
],
},
'debugger': '',
'debugger': {
message: 'Please remove all instances of debugger',
checkInTestFolder: true,
},
// Overridden APIs.
'(doc.*)\\.referrer': {
message: 'Use Viewer.getReferrerUrl() instead.',
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-facebook/1.0/test/test-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describes.sandboxed('Facebook preact component', {}, (env) => {
expect(wrapper.find('iframe')).to.have.lengthOf(1);

const iframe = wrapper.find('iframe').getDOMNode();
const spy = env.sandbox.spy(iframe, 'src', ['set']);
const spy = env.sandbox./*OK*/ spy(iframe, 'src', ['set']);
wrapper.setProps({playable: false});
expect(spy.set).to.be.calledOnce;
});
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-twitter/1.0/test/test-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describes.sandboxed('Twitter preact component v1.0', {}, (env) => {
expect(wrapper.find('iframe')).to.have.lengthOf(1);

const iframe = wrapper.find('iframe').getDOMNode();
const spy = env.sandbox.spy(iframe, 'src', ['set']);
const spy = env.sandbox./*OK*/ spy(iframe, 'src', ['set']);
wrapper.setProps({playable: false});
expect(spy.set).to.be.calledOnce;
});
Expand Down
2 changes: 1 addition & 1 deletion extensions/amp-video/0.1/test/test-amp-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ describes.realWin(
});
});

describe.only('max bitrate', () => {
describe('max bitrate', () => {
beforeEach(() => {
toggleExperiment(env.win, 'amp-story-first-page-max-bitrate', true);
});
Expand Down

0 comments on commit f5c34b9

Please sign in to comment.