diff --git a/test/metadata.test.js b/test/metadata.test.js index d0a30f51..80490460 100644 --- a/test/metadata.test.js +++ b/test/metadata.test.js @@ -36,16 +36,34 @@ const globalConfig = { }, }; -test.serial("should pass metadata code snippet", (t) => { - const config = assign({}, globalConfig, {}); +// Create a separate directory for each test so that the tests +// can run in parallel +test.cb.beforeEach((t) => { + createTestDirectory(outputDir, t.title, (err, directory) => { + if (err) return t.end(err); + t.context.directory = directory; + t.end(); + }); +}); + +test.cb.afterEach((t) => rimraf(t.context.directory, t.end)); + + +test.cb("should pass metadata code snippet", (t) => { + const config = assign({}, globalConfig, { + output: { + path: t.context.directory, + filename: "[id].metadata.js", + }, + }); webpack(config, (err) => { t.is(err, null); - fs.readdir(outputDir, (err, files) => { + fs.readdir(t.context.directory, (err, files) => { t.is(err, null); t.true(files.length > 0); - fs.readFile(path.resolve(outputDir, "reactIntlMessages.json"), + fs.readFile(path.resolve(t.context.directory, "reactIntlMessages.json"), function(err, data) { t.is(err, null); const text = data.toString(); @@ -59,8 +77,13 @@ test.serial("should pass metadata code snippet", (t) => { }); }); -test.serial("should not throw error", (t) => { - const config = assign({}, globalConfig, {}); +test.cb("should not throw error", (t) => { + const config = assign({}, globalConfig, { + output: { + path: t.context.directory, + filename: "[id].metadata.js", + }, + }); webpack(config, (err, stats) => { t.is(err, null); @@ -69,8 +92,12 @@ test.serial("should not throw error", (t) => { }); }); -test.serial("should throw error", (t) => { +test.cb("should throw error", (t) => { const config = assign({}, globalConfig, { + output: { + path: t.context.directory, + filename: "[id].metadata.js", + }, entry: "./test/fixtures/metadataErr.js", }); @@ -81,8 +108,12 @@ test.serial("should throw error", (t) => { }); }); -test.serial("should pass metadata code snippet ( cache version )", (t) => { +test.cb("should pass metadata code snippet ( cache version )", (t) => { const config = assign({}, globalConfig, { + output: { + path: t.context.directory, + filename: "[id].metadata.js", + }, module: { loaders: [ { @@ -105,10 +136,10 @@ test.serial("should pass metadata code snippet ( cache version )", (t) => { webpack(config, (err) => { t.is(err, null); - fs.readdir(outputDir, (err, files) => { + fs.readdir(t.context.directory, (err, files) => { t.is(err, null); t.true(files.length > 0); - fs.readFile(path.resolve(outputDir, "reactIntlMessages.json"), + fs.readFile(path.resolve(t.context.directory, "reactIntlMessages.json"), function(err, data) { t.is(err, null); const text = data.toString();