Skip to content

Commit 1f06b99

Browse files
committed
feat: fix failing test, remove typo
1 parent 3d12c5a commit 1f06b99

File tree

2 files changed

+61
-71
lines changed

2 files changed

+61
-71
lines changed

test/TestCases.test.js

Lines changed: 61 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,89 +9,79 @@ describe('TestCases', () => {
99
for (const directory of fs.readdirSync(casesDirectory)) {
1010
if (!/^(\.|_)/.test(directory)) {
1111
// eslint-disable-next-line no-loop-func
12-
it(
13-
`${directory} should compile to the expected result`,
14-
(done) => {
15-
const directoryForCase = path.resolve(casesDirectory, directory);
16-
const outputDirectoryForCase = path.resolve(
17-
outputDirectory,
18-
directory
12+
it(`${directory} should compile to the expected result`, (done) => {
13+
const directoryForCase = path.resolve(casesDirectory, directory);
14+
const outputDirectoryForCase = path.resolve(outputDirectory, directory);
15+
// eslint-disable-next-line import/no-dynamic-require, global-require
16+
const webpackConfig = require(path.resolve(
17+
directoryForCase,
18+
'webpack.config.js'
19+
));
20+
for (const config of [].concat(webpackConfig)) {
21+
Object.assign(
22+
config,
23+
{
24+
mode: 'none',
25+
context: directoryForCase,
26+
output: Object.assign(
27+
{
28+
path: outputDirectoryForCase,
29+
},
30+
config.output
31+
),
32+
},
33+
config
1934
);
20-
// eslint-disable-next-line import/no-dynamic-require, global-require
21-
const webpackConfig = require(path.resolve(
22-
directoryForCase,
23-
'webpack.config.js'
24-
));
25-
for (const config of [].concat(webpackConfig)) {
26-
Object.assign(
27-
config,
28-
{
29-
mode: 'none',
30-
context: directoryForCase,
31-
output: Object.assign(
32-
{
33-
path: outputDirectoryForCase,
34-
},
35-
config.output
36-
),
37-
},
38-
config
39-
);
35+
}
36+
webpack(webpackConfig, (err, stats) => {
37+
if (err) {
38+
done(err);
39+
return;
4040
}
41-
webpack(webpackConfig, (err, stats) => {
42-
if (err) {
43-
done(err);
44-
return;
45-
}
46-
done();
47-
// eslint-disable-next-line no-console
48-
console.log(
49-
stats.toString({
50-
context: path.resolve(__dirname, '..'),
51-
chunks: true,
52-
chunkModules: true,
53-
modules: false,
54-
})
55-
);
56-
if (stats.hasErrors()) {
57-
done(
58-
new Error(
59-
stats.toString({
60-
context: path.resolve(__dirname, '..'),
61-
errorDetails: true,
62-
})
63-
)
64-
);
65-
return;
66-
}
67-
const expectedDirectory = path.resolve(
68-
directoryForCase,
69-
'expected'
41+
done();
42+
// eslint-disable-next-line no-console
43+
console.log(
44+
stats.toString({
45+
context: path.resolve(__dirname, '..'),
46+
chunks: true,
47+
chunkModules: true,
48+
modules: false,
49+
})
50+
);
51+
if (stats.hasErrors()) {
52+
done(
53+
new Error(
54+
stats.toString({
55+
context: path.resolve(__dirname, '..'),
56+
errorDetails: true,
57+
})
58+
)
7059
);
60+
return;
61+
}
62+
const expectedDirectory = path.resolve(directoryForCase, 'expected');
7163

72-
for (const file of walkSync(expectedDirectory)) {
73-
const actualFilePath = file.replace(
74-
new RegExp(`/cases/${directory}/expected/`),
75-
`/js/${directory}/`
76-
);
77-
const expectedContent = fs.readFileSync(file, 'utf-8');
78-
const actualContent = fs.readFileSync(actualFilePath, 'utf-8');
64+
for (const file of walkSync(expectedDirectory)) {
65+
const actualFilePath = file.replace(
66+
new RegExp(`/cases/${directory}/expected/`),
67+
`/js/${directory}/`
68+
);
69+
const expectedContent = fs.readFileSync(file, 'utf-8');
70+
const actualContent = fs.readFileSync(actualFilePath, 'utf-8');
7971

80-
expect(actualContent).toEqual(expectedContent);
81-
}
82-
done();
83-
});
84-
},
85-
10000
86-
);
72+
expect(actualContent).toEqual(expectedContent);
73+
}
74+
done();
75+
});
76+
}, 10000);
8777
}
8878
}
8979
});
9080

9181
/**
9282
* Synchronously traverse directory of files
9383
* @param {String} dir
94-
* @returns {String} // path to file or directory
84+
* @returns {String} path to file or directory
9585
*/
9686
function* walkSync(dir) {
9787
for (const file of fs.readdirSync(dir)) {

0 commit comments

Comments
 (0)