mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-26 14:15:50 +08:00
[internal] Separate out kitchensink test into two (#4767)
* support scoped packages for cra --scripts-version option * seperate out kitchensink test * add eject to node 6 testing * travis node 6 eject * fix CI warnings
This commit is contained in:
committed by
Ian Sutherland
parent
706b319633
commit
366e5d3475
@@ -35,6 +35,7 @@ describe('Integration', () => {
|
||||
'x-from-development-env'
|
||||
);
|
||||
}
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('NODE_PATH', async () => {
|
||||
@@ -43,6 +44,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-node-path').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('PUBLIC_URL', async () => {
|
||||
@@ -58,6 +60,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href')
|
||||
).to.equal(`${prefix}/favicon.ico`);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('shell env variables', async () => {
|
||||
@@ -66,6 +69,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-shell-env-variables').textContent
|
||||
).to.equal('fromtheshell.');
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('expand .env variables', async () => {
|
||||
@@ -83,6 +87,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-expand-env-existing').textContent
|
||||
).to.equal('fromtheshell');
|
||||
doc.defaultView.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -62,6 +62,7 @@ export default feature =>
|
||||
created: (_, win) =>
|
||||
win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true),
|
||||
deferClose: true,
|
||||
pretendToBeVisual: true,
|
||||
resourceLoader,
|
||||
url: `${host}#${feature}`,
|
||||
virtualConsole: jsdom.createVirtualConsole().sendTo(console),
|
||||
|
||||
@@ -16,6 +16,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-array-destructuring').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('array spread', async () => {
|
||||
@@ -24,6 +25,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-array-spread').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('async/await', async () => {
|
||||
@@ -32,6 +34,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-async-await').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('class properties', async () => {
|
||||
@@ -40,6 +43,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-class-properties').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('computed properties', async () => {
|
||||
@@ -48,6 +52,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-computed-properties').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('custom interpolation', async () => {
|
||||
@@ -56,6 +61,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-custom-interpolation').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('default parameters', async () => {
|
||||
@@ -64,6 +70,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-default-parameters').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('destructuring and await', async () => {
|
||||
@@ -72,6 +79,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-destructuring-and-await').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('generators', async () => {
|
||||
@@ -80,6 +88,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-generators').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('object destructuring', async () => {
|
||||
@@ -88,6 +97,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-object-destructuring').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('object spread', async () => {
|
||||
@@ -96,6 +106,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-object-spread').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('promises', async () => {
|
||||
@@ -104,6 +115,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-promises').childElementCount).to.equal(
|
||||
4
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('rest + default', async () => {
|
||||
@@ -112,6 +124,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-rest-and-default').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('rest parameters', async () => {
|
||||
@@ -120,6 +133,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-rest-parameters').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('template interpolation', async () => {
|
||||
@@ -128,6 +142,7 @@ describe('Integration', () => {
|
||||
expect(
|
||||
doc.getElementById('feature-template-interpolation').childElementCount
|
||||
).to.equal(4);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,63 +11,75 @@ import url from 'url';
|
||||
|
||||
const matchCSS = (doc, regexes) => {
|
||||
if (process.env.E2E_FILE) {
|
||||
const elements = doc.getElementsByTagName('link');
|
||||
let href = "";
|
||||
for (const elem of elements) {
|
||||
if (elem.rel === 'stylesheet') {
|
||||
href = elem.href;
|
||||
}
|
||||
const elements = doc.getElementsByTagName('link');
|
||||
let href = '';
|
||||
for (const elem of elements) {
|
||||
if (elem.rel === 'stylesheet') {
|
||||
href = elem.href;
|
||||
}
|
||||
resourceLoader(
|
||||
{ url: url.parse(href) },
|
||||
(_, textContent) => {
|
||||
for (const regex of regexes) {
|
||||
expect(textContent).to.match(regex);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
resourceLoader({ url: url.parse(href) }, (_, textContent) => {
|
||||
for (const regex of regexes) {
|
||||
expect(textContent).to.match(regex);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (let i = 0; i < regexes.length; ++i) {
|
||||
expect(doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '')).to.match(regexes[i]);
|
||||
expect(
|
||||
doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '')
|
||||
).to.match(regexes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe('Integration', () => {
|
||||
describe('Webpack plugins', () => {
|
||||
it('css inclusion', async () => {
|
||||
const doc = await initDOM('css-inclusion');
|
||||
matchCSS(doc, [/html\{/, /#feature-css-inclusion\{background:.+;color:.+}/]);
|
||||
matchCSS(doc, [
|
||||
/html\{/,
|
||||
/#feature-css-inclusion\{background:.+;color:.+}/,
|
||||
]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('css modules inclusion', async () => {
|
||||
const doc = await initDOM('css-modules-inclusion');
|
||||
matchCSS(doc, [/.+style_cssModulesInclusion__.+\{background:.+;color:.+}/,
|
||||
/.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/]);
|
||||
matchCSS(doc, [
|
||||
/.+style_cssModulesInclusion__.+\{background:.+;color:.+}/,
|
||||
/.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/,
|
||||
]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('scss inclusion', async () => {
|
||||
const doc = await initDOM('scss-inclusion');
|
||||
matchCSS(doc, [/#feature-scss-inclusion\{background:.+;color:.+}/]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('scss modules inclusion', async () => {
|
||||
const doc = await initDOM('scss-modules-inclusion');
|
||||
matchCSS(doc, [/.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/,
|
||||
/.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/]);
|
||||
|
||||
matchCSS(doc, [
|
||||
/.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/,
|
||||
/.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/,
|
||||
]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('sass inclusion', async () => {
|
||||
const doc = await initDOM('sass-inclusion');
|
||||
matchCSS(doc, [/#feature-sass-inclusion\{background:.+;color:.+}/]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('sass modules inclusion', async () => {
|
||||
const doc = await initDOM('sass-modules-inclusion');
|
||||
matchCSS(doc, [/.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/,
|
||||
/.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/]);
|
||||
matchCSS(doc, [
|
||||
/.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/,
|
||||
/.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/,
|
||||
]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('graphql files inclusion', async () => {
|
||||
@@ -78,6 +90,7 @@ describe('Integration', () => {
|
||||
expect(children[0].textContent.replace(/\s/g, '')).to.equal(
|
||||
'{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}'
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('image inclusion', async () => {
|
||||
@@ -86,6 +99,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-image-inclusion').src).to.match(
|
||||
/^data:image\/jpeg;base64.+==$/
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('no ext inclusion', async () => {
|
||||
@@ -94,6 +108,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-no-ext-inclusion').href).to.match(
|
||||
/\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('json inclusion', async () => {
|
||||
@@ -102,6 +117,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-json-inclusion').textContent).to.equal(
|
||||
'This is an abstract.'
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('linked modules', async () => {
|
||||
@@ -110,6 +126,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-linked-modules').textContent).to.equal(
|
||||
'2.0.0'
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('svg inclusion', async () => {
|
||||
@@ -117,6 +134,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-svg-inclusion').src).to.match(
|
||||
/\/static\/media\/logo\..+\.svg$/
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('svg component', async () => {
|
||||
@@ -125,11 +143,13 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-svg-component').textContent).to.equal(
|
||||
''
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('svg in css', async () => {
|
||||
const doc = await initDOM('svg-in-css');
|
||||
matchCSS(doc, [/\/static\/media\/logo\..+\.svg/]);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
|
||||
it('unknown ext inclusion', async () => {
|
||||
@@ -138,6 +158,7 @@ describe('Integration', () => {
|
||||
expect(doc.getElementById('feature-unknown-ext-inclusion').href).to.match(
|
||||
/\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/
|
||||
);
|
||||
doc.defaultView.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user