avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Support arguments in "require" configuration #1666

Closed novemberborn closed 1 year ago

novemberborn commented 6 years ago

Issuehunt badges

Prompted by #1665 and inspired by Babel's plugin / preset configuration, it'd be neat to do this:

"ava": {
  "require": [
    ["@babel/register", {
      "ignore": ["test/*"]
    }]
  ]
}

If an array is provided we'd require the module, resolve any __esModules / default shenanigans, and invoke .apply() with the remaining values. We should support any number of arguments.


IssueHunt Summary #### [sculpt0r sculpt0r](https://oss.issuehunt.io/u/sculpt0r) has been rewarded. ### Backers (Total: $40.00) - [issuehunt issuehunt](https://oss.issuehunt.io/u/issuehunt) ($40.00) ### Submitted pull Requests - [#3184 feat: handle complex `options.require` config property](https://oss.issuehunt.io/r/avajs/ava/pull/3184) --- ### Tips - Checkout the [Issuehunt explorer](https://oss.issuehunt.io/r/avajs/ava/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://oss.issuehunt.io/r/new) on IssueHunt to raise funds.
Jolo510 commented 6 years ago

Hey @novemberborn, I'd like to take on this task!

novemberborn commented 6 years ago

@Jolo510 awesome, go for it!

anayaml commented 6 years ago

Hey, @novemberborn, I'd like to work on this task

novemberborn commented 6 years ago

@amslv awesome, thanks!

Since this issue was opened, we added support for ava.config.js files. We need to make sure the arguments can be stringified as JSON and then parsed in the worker processes.

We could do the stringifying and the parsing in the main process first, and then use our "deep equal" logic to make sure the values are the same: https://github.com/avajs/ava/blob/6d12abfdff4478a1b6f4e87237764b89eb05f18d/lib/assert.js#L282

IssueHuntBot commented 5 years ago

@issuehunt has funded $40.00 to this issue.


stavalfi commented 4 years ago

@novemberborn

I don't understand your comment. are you proposing a way to solve this issue? if yes, can you explain in different way?

@amslv awesome, thanks!

Since this issue was opened, we added support for ava.config.js files. We need to make sure the arguments can be stringified as JSON and then parsed in the worker processes.

We could do the stringifying and the parsing in the main process first, and then use our "deep equal" logic to make sure the values are the same:

https://github.com/avajs/ava/blob/6d12abfdff4478a1b6f4e87237764b89eb05f18d/lib/assert.js#L282


I did some research and it seems that i must create a temp-js-file that will contain the call to @babel/register with all it's options and add it to the ava.require section.

do you think my idea is ok?

novemberborn commented 4 years ago

@stavalfi I'm not sure what your question is. Could you rephrase it?

niteshsarode commented 4 years ago

@novemberborn Is anyone working on this issue? Can I give it a try?

novemberborn commented 4 years ago

@niteshsarode please do!

Om-Vg commented 4 years ago

@novemberborn I would like to give this a try if no-one's working on it

novemberborn commented 4 years ago

@OmLakshmi yes, that'd be great, thanks.

@niteshsarode please do let us know if you are about to submit a pull request 😄

webobite commented 4 years ago

Hi @novemberborn I would like to give it a try. Will let u know If I am able to solve this issue.

Thanks

webobite commented 4 years ago

@amslv awesome, thanks!

Since this issue was opened, we added support for ava.config.js files. We need to make sure the arguments can be stringified as JSON and then parsed in the worker processes.

We could do the stringifying and the parsing in the main process first, and then use our "deep equal" logic to make sure the values are the same:

https://github.com/avajs/ava/blob/6d12abfdff4478a1b6f4e87237764b89eb05f18d/lib/assert.js#L282

I would like to ask you about this comment. As in this Comment You stated about the main process One need to compare the JSON(arguments) and then use the deepEqual from assert.js (Correct me If I am wrong). As I am new to this repo Can You let me know where exactly the main process code block is there. I tried to trace it from index,js --> worker/main.js --> and then it goes on to chain () call ... I am new to openSource community. So Is their any documentation resource (You can point out if available) to understand the specifically workflow of the AVA testing framework which can be used here ?

novemberborn commented 4 years ago

The main process is what loads the configuration. Essentially we can add a validation step before this return: https://github.com/avajs/ava/blob/b71f396df7b9d74ef24262b6840df1593cad3798/lib/load-config.js#L163

You wouldn't use assert.js itself. Load Concordance instead and use the compare() function. I don't think you'd need to pass any options.

yliu481 commented 3 years ago

Hi, @novemberborn

Can I work on this issue? I would like to give it a try.

Thanks

novemberborn commented 3 years ago

@yliu481 of course, thanks!

yliu481 commented 3 years ago

@novemberborn Before starting, I want to make sure we are on the same pages, so I checked 06-configuration.md and understand that ava can load configuration from either package.json or an ava.config.* file.

I checked the load-config.js, these codes will load the ava.config.* https://github.com/avajs/ava/blob/32c5425353cc58422f0a196bb0c06a4095a33825/lib/load-config.js#L204-L206

And in the https://github.com/avajs/ava/blob/32c5425353cc58422f0a196bb0c06a4095a33825/lib/load-config.js#L45 usually, this will call evaluateJsConfig and run ava.config.js https://github.com/avajs/ava/blob/32c5425353cc58422f0a196bb0c06a4095a33825/lib/load-config.js#L20-L21

This is how to load ava.config.js right now.

Could you please tell me if I am right?

Also, it is the evaluateJsConfig function that I need to improve, am I right?

novemberborn commented 3 years ago

No, you need to change how the require array is processed here:

https://github.com/avajs/ava/blob/32c5425353cc58422f0a196bb0c06a4095a33825/lib/worker/subprocess.js#L217-L218

The array could contain just a ref string, or another array [ref, ...args]. In that case, after loading the module, we'd invoked the result with those arguments (mod(...args)).

dudeman9801 commented 3 years ago

Hi @novemberborn, I would like to give this issue a try. Thanks

novemberborn commented 3 years ago

Go for it @abhnvgupta.

basker26 commented 3 years ago

hi @novemberborn, if no one is working on shall I try

dudeman9801 commented 3 years ago

@novemberborn please de-assign me, I'm not able to find the time. Sorry about that

novemberborn commented 3 years ago

@abhnvgupta thanks for letting us know @abhnvgupta, better luck next time! 😄

thyrhone commented 2 years ago

is it still possible to work on this?

novemberborn commented 2 years ago

@thyrhone all yours.

sculpt0r commented 1 year ago

Hey @novemberborn , I assume this issue is free to take now? Could you tell me if there is anything special here - since there is a lot of people resign from doing this?

Avelas1234 commented 1 year ago

Idk but someone is framing me, took my password and profile for like 20 years or more

On Sat, Feb 25, 2023 at 11:52 AM Bartłomiej Kalemba < @.***> wrote:

Hey @novemberborn https://github.com/novemberborn , I assume this issue is free to take now? Could you tell me if there is anything special here - since there is a lot of people resign of doing this?

— Reply to this email directly, view it on GitHub https://github.com/avajs/ava/issues/1666#issuecomment-1445191484, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52PLFPUUF7XKMSAXSIXC53WZJPJBANCNFSM4EN7DF5A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Avelas1234 commented 1 year ago

There’s someone on my profile it has all my information. It has my Gmail account and all my social media accounts and I’ll be trying to login but faster than me logging in.

On Sat, Feb 25, 2023 at 7:00 PM The Old Man 559 @.***> wrote:

Idk but someone is framing me, took my password and profile for like 20 years or more

On Sat, Feb 25, 2023 at 11:52 AM Bartłomiej Kalemba < @.***> wrote:

Hey @novemberborn https://github.com/novemberborn , I assume this issue is free to take now? Could you tell me if there is anything special here - since there is a lot of people resign of doing this?

— Reply to this email directly, view it on GitHub https://github.com/avajs/ava/issues/1666#issuecomment-1445191484, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52PLFPUUF7XKMSAXSIXC53WZJPJBANCNFSM4EN7DF5A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Avelas1234 commented 1 year ago

I have the right back to you it’s not going to be mean here’s my personal number 559-356-1564

On Sat, Feb 25, 2023 at 7:00 PM The Old Man 559 @.***> wrote:

There’s someone on my profile it has all my information. It has my Gmail account and all my social media accounts and I’ll be trying to login but faster than me logging in.

On Sat, Feb 25, 2023 at 7:00 PM The Old Man 559 @.***> wrote:

Idk but someone is framing me, took my password and profile for like 20 years or more

On Sat, Feb 25, 2023 at 11:52 AM Bartłomiej Kalemba < @.***> wrote:

Hey @novemberborn https://github.com/novemberborn , I assume this issue is free to take now? Could you tell me if there is anything special here - since there is a lot of people resign of doing this?

— Reply to this email directly, view it on GitHub https://github.com/avajs/ava/issues/1666#issuecomment-1445191484, or unsubscribe https://github.com/notifications/unsubscribe-auth/A52PLFPUUF7XKMSAXSIXC53WZJPJBANCNFSM4EN7DF5A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

novemberborn commented 1 year ago

@sculpt0r yep. No I don't think there's anything special about it.

sculpt0r commented 1 year ago

So @novemberborn - could you assign me to to this ticket?

novemberborn commented 1 year ago

@sculpt0r just start the work, I doubt anybody will jump in before you.

1shubhankar9 commented 1 year ago

@novemberborn could you assign me to this ticket

BT616 commented 1 year ago

Can i try this task?

novemberborn commented 1 year ago

This will land in #3184.

utkarsh-shrivastav77 commented 1 year ago

Hi is this issue still open

novemberborn commented 1 year ago

No, this will land in #3184.