Skip to content

test: issue with global .asyncapi file getting overwritten while testing#27

Merged
magicmatatjahu merged 2 commits intoasyncapi:masterfrom
Souvikns:fix-#23
Jul 13, 2021
Merged

test: issue with global .asyncapi file getting overwritten while testing#27
magicmatatjahu merged 2 commits intoasyncapi:masterfrom
Souvikns:fix-#23

Conversation

@Souvikns
Copy link
Member

Description

  • Running integration testing was overwriting the global .asyncapi file and it was quite annoying while developing.
  • We basically check if the NODE_ENV is test, and use .test.asyncapi file to do all the testing related operations.

Related issue(s)
Fixes #23

@magicmatatjahu
Copy link
Member

In your issue you have:

It would be nice to configure the root context service to load context from different files.

Of course not in this PR, but maybe we should have something like global config for CLI with info about path to the asyncapi context?

And last, please change the prefix for PR title to test not fix, we don't fix the code, but only fix the tests :)

@Souvikns Souvikns changed the title fix: issue with global .asyncapi file getting overwritten while testing test: issue with global .asyncapi file getting overwritten while testing Jul 13, 2021
@magicmatatjahu
Copy link
Member

@Souvikns You have one workflow which didn't pass :)

@Souvikns
Copy link
Member Author

Yeah, I am trying to figure that out because test cases are passing in windows and ubuntu, only failing in macOS.

@Souvikns
Copy link
Member Author

@magicmatatjahu can you rerun that specific action once, because it is running in my local machine.

sreenshot

image

src/constants.ts Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that jest only set to NODE_ENV the test if NODE_ENV isn't defined - https://jestjs.io/docs/environment-variables#node_env so maybe https://jestjs.io/docs/environment-variables#jest_worker_id will be better to check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or make the fallback to check JEST_WORKER_ID.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I check for JEST_WORKER_ID it does not work and my .asyncapi file gets updated again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even as process.env.JEST_WORKER_ID !== undefined;? So maybe we should change it to the:

Suggested change
export const CONTEXT_FILENAME = (process.env['NODE_ENV'] === "test")? ".test.asyncapi": ".asyncapi";
const isTestEnv = (process.env['NODE_ENV'] === "test") || (process.env['JEST_WORKER_ID'] !== undefined) || typeof jest !== 'undefined';
export const CONTEXT_FILENAME = isTestEnv ? ".test.asyncapi" : ".asyncapi";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working

@magicmatatjahu magicmatatjahu merged commit 8138299 into asyncapi:master Jul 13, 2021
@Souvikns Souvikns deleted the fix-#23 branch July 15, 2021 04:16
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running integration testing the global context file is getting updated

3 participants

Comments