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

Add test setup for v3 #9889

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Add test setup for v3 #9889

merged 2 commits into from
Aug 2, 2024

Conversation

MonicaOlejniczak
Copy link
Contributor

@MonicaOlejniczak MonicaOlejniczak commented Aug 2, 2024

↪️ Pull Request

Adds V3 tests to CI via a new testing API that utilises a PARCEL_V3 environment variable to switch between which set of tests are to be run

Note that the parcelVersion logic may need to be refined later as needed

🤔 Considerations

Globals

I initially tried to override the globally defined describe and it rather than having to directly import the wrappers, but there are a couple of issues:

  • when the globals are defined in another file such as the test utils, it either results in a circular reference or mocha is unable to attach the it handler due to its intertwined suite context
  • the globals must be inlined in the test file itself, which even if generated will not have a good developer experience (lack of findable definitions, and slower performance due to code injection)

It also wasn't possible to use a root hook plugin or global fixture to inject the values.

💻 Examples

Run tests in both v2 and v3

describe('parcel', () => {
  it('bundles');
});

Run tests in v2 only

describe.v2('parcel', () => {
  it('bundles');
});

it.v2('test');

Run tests in v3 only

describe.v3('parcel', () => {
  it('bundles');
});

it.v3('test');

Run tests selectively in v2, v3, or both

describe('parcel', () => {
  it('bundles for both v2 and v3');

  it.v2('bundles for v2');

  it.v3('bundles for v3');
});

🚨 Test instructions

yarn test:integration

PARCEL_V3=false yarn test:integration

PARCEL_V3=true yarn test:integration

@MonicaOlejniczak MonicaOlejniczak merged commit dc29a25 into v2 Aug 2, 2024
23 checks passed
@MonicaOlejniczak MonicaOlejniczak deleted the molejniczak/v3-tests branch August 2, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants