Skip to content

Commit 136096f

Browse files
committed
Add e2e test for relative paths
1 parent 06a1338 commit 136096f

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fs = require('fs-extra');
2+
const globby = require('globby');
3+
const path = require('path');
4+
const {
5+
bootstrap,
6+
isSuccessfulDevelopment,
7+
isSuccessfulProduction,
8+
} = require('../../utils');
9+
beforeEach(async () => {
10+
await bootstrap({ directory: global.testDirectory, template: __dirname });
11+
});
12+
13+
describe('relative paths', () => {
14+
// TODO: enable when development relative paths are supported
15+
xit('builds in development', async () => {
16+
await isSuccessfulDevelopment({ directory: global.testDirectory });
17+
});
18+
it('builds in production', async () => {
19+
await isSuccessfulProduction({ directory: global.testDirectory });
20+
21+
const buildDir = path.join(global.testDirectory, 'build');
22+
const cssFile = path.join(
23+
buildDir,
24+
globby.sync('**/*.css', { cwd: buildDir }).pop()
25+
);
26+
const svgFile = path.join(
27+
buildDir,
28+
globby.sync('**/*.svg', { cwd: buildDir }).pop()
29+
);
30+
const desiredPath = /url\((.+?)\)/
31+
.exec(fs.readFileSync(cssFile, 'utf8'))
32+
.pop();
33+
expect(path.resolve(path.join(path.dirname(cssFile), desiredPath))).toBe(
34+
path.resolve(svgFile)
35+
);
36+
});
37+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"react-scripts": "latest"
4+
},
5+
"homepage": "."
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>React App</title>
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
</body>
9+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.RootSvg:before {
2+
display: block;
3+
content: ' ';
4+
background-image: url(./logo.svg);
5+
background-size: 28px 28px;
6+
height: 28px;
7+
width: 28px;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './index.css';
Loading

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"execa": "1.0.0",
2424
"fs-extra": "^7.0.0",
2525
"get-port": "^4.0.0",
26+
"globby": "^8.0.1",
2627
"husky": "1.0.0-rc.15",
2728
"jest": "^23.6.0",
2829
"lerna": "2.9.1",

0 commit comments

Comments
 (0)