Skip to content

Commit

Permalink
Add test setup for v3 (#9889)
Browse files Browse the repository at this point in the history
  • Loading branch information
MonicaOlejniczak authored Aug 2, 2024
1 parent 6f80bf1 commit dc29a25
Show file tree
Hide file tree
Showing 80 changed files with 4,850 additions and 10,080 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ jobs:
packages/core/rust/*.node
integration_tests:
name: Integration tests (${{ matrix.os }}, Node ${{ matrix.node }})
name: Integration tests (${{ matrix.version == 'v3' && 'v3, ' || '' }}${{ matrix.os }}, Node ${{ matrix.node }})
strategy:
matrix:
node: [18, 20]
os: [ubuntu-latest, macos-latest, windows-latest]
version: [v2, v3]
# These tend to be quite flakey, so one failed instance shouldn't stop
# others from potentially succeeding
fail-fast: false
Expand All @@ -123,6 +124,8 @@ jobs:
- run: yarn build-native-release
- run: yarn build
- run: yarn test:integration-ci
env:
PARCEL_V3: ${{ matrix.version == 'v3' && 'true' || 'false' }}

# Deployment steps taken from https://github.com/colinwilson/static-site-to-vercel/blob/master/.github/workflows/deploy-preview.yml
repl_build:
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/BundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import assert from 'assert';
import path from 'path';
import {bundle, fsFixture, overlayFS} from '@parcel/test-utils';
import {bundle, describe, fsFixture, it, overlayFS} from '@parcel/test-utils';
import type {BundleGraph, BundleGroup, PackagedBundle} from '@parcel/types';

describe('BundleGraph', () => {
describe.v2('BundleGraph', () => {
it('can traverse assets across bundles and contexts', async () => {
let b = await bundle(
path.join(__dirname, '/integration/worker-shared/index.js'),
Expand Down
14 changes: 8 additions & 6 deletions packages/core/integration-tests/test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
import path from 'path';
import assert from 'assert';
import {
distDir,
bundle,
assertBundles,
bundle,
describe,
distDir,
fsFixture,
it,
outputFS,
overlayFS,
fsFixture,
} from '@parcel/test-utils';

import {PARCEL_VERSION} from '../../core/src/constants';

describe('JS API', function () {
describe.v2('JS API', function () {
it('should respect distEntry', async function () {
const NAME = 'custom-name.js';

Expand Down Expand Up @@ -68,7 +70,7 @@ describe('JS API', function () {
await fsFixture(overlayFS, dir)`
index.js:
export default 'Hi';
.parcelrc:
{
extends: "@parcel/config-default",
Expand All @@ -81,7 +83,7 @@ describe('JS API', function () {
}
yarn.lock:
reporter-plugin.js:
import {Reporter} from '@parcel/plugin';
import path from 'node:path';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import path from 'path';
import {
bundle,
bundler,
describe,
distDir,
getNextBuild,
inputFS as fs,
it,
outputFS,
removeDistDirectory,
run,
Expand All @@ -22,7 +24,7 @@ import {md} from '@parcel/diagnostic';
const parcelCli = require.resolve('parcel/src/bin.js');
const inputDir = path.join(__dirname, '/input');

describe('babel', function () {
describe.v2('babel', function () {
let subscription;
beforeEach(async function () {
// TODO maybe don't do this for all tests
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/blob-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';
import path from 'path';
import {bundle, distDir, outputFS, run} from '@parcel/test-utils';
import {bundle, describe, distDir, it, outputFS, run} from '@parcel/test-utils';

class Blob {
data;
Expand All @@ -18,7 +18,7 @@ const URL = {
},
};

describe('blob urls', () => {
describe.v2('blob urls', () => {
it('should inline compiled content as a blob url with `blob-url:*` imports', async () => {
let b = await bundle(
path.join(__dirname, '/integration/blob-url/index.js'),
Expand Down
10 changes: 6 additions & 4 deletions packages/core/integration-tests/test/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import path from 'path';
import assert from 'assert';
import Logger from '@parcel/logger';
import {
bundle,
assertBundles,
bundle,
describe,
findAsset,
it,
overlayFS,
fsFixture,
run,
} from '@parcel/test-utils';
import {hashString} from '@parcel/rust';
import {normalizePath} from '@parcel/utils';

describe('bundler', function () {
describe.v2('bundler', function () {
it('should not create shared bundles when a bundle is being reused and disableSharedBundles is enabled', async function () {
await fsFixture(overlayFS, __dirname)`
disable-shared-bundle-single-source
Expand Down Expand Up @@ -1877,11 +1879,11 @@ describe('bundler', function () {
index.html:
<link rel="stylesheet" type="text/css" href="./style.css">
<script src="./index.js" type="module"></script>
style.css:
@import "common.css";
body { color: red }
common.css:
.common { color: green }
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import path from 'path';
import {
assertBundles,
bundler,
describe,
it,
run,
runBundle as runSingleBundle,
overlayFS,
Expand Down Expand Up @@ -117,7 +119,7 @@ async function testCache(update: UpdateFn | TestConfig, integration) {
return b;
}

describe('cache', function () {
describe.v2('cache', function () {
before(async () => {
await inputFS.rimraf(path.join(__dirname, 'input'));
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/compressors.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from 'assert';
import path from 'path';
import zlib from 'zlib';
import {bundle, outputFS, distDir} from '@parcel/test-utils';
import {bundle, describe, it, outputFS, distDir} from '@parcel/test-utils';

describe('compressors', function () {
describe.v2('compressors', function () {
it('should not compress output with gzip and brotli in development', async function () {
await bundle(path.join(__dirname, 'integration/compressors/index.js'));

Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/config-merging.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {bundle, run, outputFS} from '@parcel/test-utils';
import {bundle, describe, it, run, outputFS} from '@parcel/test-utils';
import assert from 'assert';
import path from 'path';

describe('config merging', function () {
describe.v2('config merging', function () {
it('should merge incomplete config packages', async function () {
let b = await bundle(
path.join(__dirname, '/integration/config-merging/index.js'),
Expand Down
11 changes: 9 additions & 2 deletions packages/core/integration-tests/test/contentHashing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import assert from 'assert';
import path from 'path';
import {bundle as _bundle, overlayFS, outputFS, ncp} from '@parcel/test-utils';
import {
bundle as _bundle,
describe,
it,
overlayFS,
outputFS,
ncp,
} from '@parcel/test-utils';

const distDir = path.join(__dirname, './dist');

Expand All @@ -14,7 +21,7 @@ function bundle(path) {
});
}

describe('content hashing', function () {
describe.v2('content hashing', function () {
beforeEach(async () => {
await outputFS.rimraf(path.join(__dirname, '/input'));
});
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/css-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import assert from 'assert';
import path from 'path';
import {
bundle,
describe,
it,
run,
runBundle,
assertBundles,
Expand All @@ -12,7 +14,7 @@ import {
} from '@parcel/test-utils';
import postcss from 'postcss';

describe('css modules', () => {
describe.v2('css modules', () => {
it('should support transforming css modules (require)', async () => {
let b = await bundle(
path.join(__dirname, '/integration/postcss-modules-cjs/index.js'),
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import assert from 'assert';
import path from 'path';
import {
bundle,
describe,
it,
run,
assertBundles,
distDir,
Expand All @@ -11,7 +13,7 @@ import {
outputFS,
} from '@parcel/test-utils';

describe('css', () => {
describe.v2('css', () => {
afterEach(async () => {
await removeDistDirectory();
});
Expand Down
6 changes: 4 additions & 2 deletions packages/core/integration-tests/test/elm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import assert from 'assert';
import path from 'path';
import {
assertBundles,
bundle,
describe,
distDir,
assertBundles,
it,
run,
outputFS,
} from '@parcel/test-utils';

describe('elm', function () {
describe.v2('elm', function () {
it('should produce a basic Elm bundle', async function () {
let b = await bundle(path.join(__dirname, '/integration/elm/index.js'));

Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/encodedURI.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';
import path from 'path';
import {bundle, outputFS, distDir} from '@parcel/test-utils';
import {bundle, describe, it, outputFS, distDir} from '@parcel/test-utils';

describe('encodedURI', function () {
describe.v2('encodedURI', function () {
it('should support bundling files which names in encoded URI', async function () {
await bundle(path.join(__dirname, '/integration/encodedURI/index.html'));

Expand Down
4 changes: 2 additions & 2 deletions packages/core/integration-tests/test/eslint-validation.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @flow
import assert from 'assert';
import path from 'path';
import {bundle} from '@parcel/test-utils';
import {bundle, describe, it} from '@parcel/test-utils';

const config = path.join(
__dirname,
'./integration/custom-configs/.parcelrc-eslint',
);

describe('eslint-validator', function () {
describe.v2('eslint-validator', function () {
it('should throw validation error with eslint errors', async function () {
let didThrow = false;
let entry = path.join(__dirname, '/integration/eslint-error/index.js');
Expand Down
17 changes: 12 additions & 5 deletions packages/core/integration-tests/test/feature-flags.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import assert from 'assert';
import path from 'node:path';
import {rimraf} from 'rimraf';
import {bundle, run, overlayFS, fsFixture} from '@parcel/test-utils';

describe('feature flags', () => {
import {
bundle,
describe,
it,
run,
overlayFS,
fsFixture,
} from '@parcel/test-utils';

describe.v2('feature flags', () => {
let dir = path.join(__dirname, 'feature-flags-fixture');
beforeEach(async () => {
await rimraf(dir);
Expand All @@ -20,7 +27,7 @@ describe('feature flags', () => {
index.js:
module.exports = "MARKER";
.parcelrc:
{
extends: "@parcel/config-default",
Expand All @@ -35,7 +42,7 @@ describe('feature flags', () => {
transformers: {
'*.js': ['./transformer-client.js', '...']
},
}
}
transformer.js:
const {Transformer} = require('@parcel/plugin');
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import path from 'path';
import {
assertBundles,
bundle,
describe,
it,
removeDistDirectory,
run,
overlayFS,
outputFS,
distDir,
} from '@parcel/test-utils';

describe('fs', function () {
describe.v2('fs', function () {
beforeEach(async () => {
await removeDistDirectory();
});
Expand Down
4 changes: 3 additions & 1 deletion packages/core/integration-tests/test/glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import assert from 'assert';
import path from 'path';
import {
bundle,
describe,
it,
run,
assertBundles,
outputFS,
inputFS,
} from '@parcel/test-utils';
import nullthrows from 'nullthrows';

describe('glob', function () {
describe.v2('glob', function () {
it('should require a glob of files', async function () {
let b = await bundle(path.join(__dirname, '/integration/glob/index.js'));

Expand Down
11 changes: 9 additions & 2 deletions packages/core/integration-tests/test/globals.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import assert from 'assert';
import path from 'path';

import {bundle, fsFixture, overlayFS, run} from '@parcel/test-utils';
import {
bundle,
describe,
fsFixture,
it,
overlayFS,
run,
} from '@parcel/test-utils';
import sinon from 'sinon';

describe('globals', function () {
describe.v2('globals', function () {
it('should support global alias syntax', async function () {
let b = await bundle(
path.join(__dirname, '/integration/global-alias/index.js'),
Expand Down
Loading

0 comments on commit dc29a25

Please sign in to comment.