Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests: symlink tests, Kotlin tests, and maybe test-util module #2605

Merged
merged 7 commits into from
Feb 3, 2019
7 changes: 6 additions & 1 deletion packages/core/integration-tests/test/bundler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const assert = require('assert');
const sinon = require('sinon');
const path = require('path');
const {assertBundleTree, bundle, bundler, nextBundle} = require('./utils');
const {
assertBundleTree,
bundle,
bundler,
nextBundle
} = require('@parcel/test-utils');

describe('bundler', function() {
it('should bundle once before exporting middleware', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/contentHashing.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, rimraf, ncp} = require('./utils');
const {bundle, rimraf, ncp} = require('@parcel/test-utils');

describe('content hashing', function() {
beforeEach(async function() {
Expand Down
8 changes: 7 additions & 1 deletion packages/core/integration-tests/test/css.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree, rimraf, ncp} = require('./utils');
const {
bundle,
run,
assertBundleTree,
rimraf,
ncp
} = require('@parcel/test-utils');

describe('css', function() {
it('should produce two bundles when importing a CSS file', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/elm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree, run} = require('./utils');
const {bundle, assertBundleTree, run} = require('@parcel/test-utils');

describe('elm', function() {
it('should produce a basic Elm bundle', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/encodedURI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');

describe('encodedURI', function() {
it('should support bundling files which names in encoded URI', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const fs = require('@parcel/fs');
const path = require('path');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('fs', function() {
describe('--target=browser', function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/glob.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const fs = require('@parcel/fs');
const path = require('path');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('glob', function() {
it('should require a glob of files', async function() {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/integration-tests/test/glsl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree, normaliseNewlines} = require('./utils');
const {
bundle,
run,
assertBundleTree,
normaliseNewlines
} = require('@parcel/test-utils');

describe('glsl', function() {
it('should support requiring GLSL files via glslify', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/graphql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const gql = require('graphql-tag');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('graphql', function() {
it('should support requiring graphql files', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/hmr.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const fs = require('@parcel/fs');
const path = require('path');
const {bundler, run, rimraf, ncp} = require('./utils');
const {bundler, run, rimraf, ncp} = require('@parcel/test-utils');
const {sleep} = require('@parcel/test-utils');
const WebSocket = require('ws');
const json5 = require('json5');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');
const path = require('path');

describe('html', function() {
Expand Down
36 changes: 22 additions & 14 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const {
assertBundleTree,
deferred,
ncp
} = require('./utils');
} = require('@parcel/test-utils');
const {mkdirp} = require('@parcel/fs');
const {symlinkPrivilegeWarning} = require('@parcel/test-utils');
const {symlinkSync} = require('fs');

describe('javascript', function() {
Expand Down Expand Up @@ -1290,21 +1291,28 @@ describe('javascript', function() {
inputDir
);

// Create the symlink here to prevent cross platform and git issues
symlinkSync(
path.join(inputDir, 'packages/foo'),
path.join(inputDir, 'node_modules/foo'),
'dir'
);
try {
// Create the symlink here to prevent cross platform and git issues
symlinkSync(
path.join(inputDir, 'packages/foo'),
path.join(inputDir, 'node_modules/foo'),
'dir'
);

await bundle(inputDir + '/index.js');
await bundle(inputDir + '/index.js');

let file = await fs.readFile(
path.join(__dirname, '/dist/index.js'),
'utf8'
);
assert(file.includes('function Foo'));
assert(file.includes('function Bar'));
let file = await fs.readFile(
path.join(__dirname, '/dist/index.js'),
'utf8'
);
assert(file.includes('function Foo'));
assert(file.includes('function Bar'));
} catch (e) {
if (e.perm == 'EPERM') {
symlinkPrivilegeWarning();
this.skip();
}
}
});

it('should not compile node_modules with a source field in package.json when not symlinked', async function() {
Expand Down
10 changes: 9 additions & 1 deletion packages/core/integration-tests/test/kotlin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const assert = require('assert');
const {bundle, assertBundleTree, run} = require('./utils');
const {bundle, assertBundleTree, run} = require('@parcel/test-utils');
const commandExists = require('command-exists');

describe('kotlin', function() {
if (!commandExists.sync('java')) {
console.log(
'Skipping Kotlin tests. Install https://www.java.com/download/ to run them.'
);
return;
}

it('should produce a basic kotlin bundle', async function() {
let b = await bundle(__dirname + '/integration/kotlin/index.js');

Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/less.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('less', function() {
it('should support requiring less files', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');

describe('parser', function() {
it('should support case-insensitive file extension', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/pug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');

describe('pug', function() {
it('should support bundling HTML', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/reason.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const path = require('path');
const {bundle, run} = require('./utils');
const {bundle, run} = require('@parcel/test-utils');

describe('reason', function() {
it('should produce a bundle', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/rust.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const path = require('path');
const {bundle, bundler, run, assertBundleTree} = require('./utils');
const {bundle, bundler, run, assertBundleTree} = require('@parcel/test-utils');
const fs = require('@parcel/fs');
const commandExists = require('command-exists');

Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/sass.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('sass', function() {
it('should support requiring sass files', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/schema-jsonld.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');

describe('schema ld+json', function() {
it('Should parse a LD+JSON schema and collect dependencies', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/scope-hoisting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const path = require('path');
const {bundle: _bundle, run} = require('./utils');
const {bundle: _bundle, run} = require('@parcel/test-utils');
const fs = require('@parcel/fs');

const bundle = (name, opts = {}) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const logger = require('@parcel/logger');
const {bundler} = require('./utils');
const {bundler} = require('@parcel/test-utils');
const http = require('http');
const https = require('https');
const sinon = require('sinon');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const assert = require('assert');
const fs = require('@parcel/fs');
const path = require('path');
const mapValidator = require('sourcemap-validator');
const {bundler, bundle, run, assertBundleTree} = require('./utils');
const {bundler, bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('sourcemaps', function() {
it('should create a valid sourcemap as a child of a JS bundle', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/stylus.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('stylus', function() {
it('should support requiring stylus files', async function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/sugarss.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const {bundle, assertBundleTree} = require('./utils');
const {bundle, assertBundleTree} = require('@parcel/test-utils');
const fs = require('@parcel/fs');
const path = require('path');

Expand Down
2 changes: 1 addition & 1 deletion packages/core/integration-tests/test/typescript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const fs = require('@parcel/fs');
const {bundle, run, assertBundleTree} = require('./utils');
const {bundle, run, assertBundleTree} = require('@parcel/test-utils');

describe('typescript', function() {
it('should produce a ts bundle using ES6 imports', async function() {
Expand Down
Loading