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

ReferenceError: abp is not defined in reactjs while testing #4582

Open
sivaprabha123 opened this issue Feb 15, 2019 · 8 comments
Open

ReferenceError: abp is not defined in reactjs while testing #4582

sivaprabha123 opened this issue Feb 15, 2019 · 8 comments

Comments

@sivaprabha123
Copy link

Please find the error attached which occurs when I create a new React Component named 'tableIcon.tsx' and run a test suite for the same.

githubsivaerror

@ismcagdas
Copy link
Member

@siva26051990 I got the same error as https://github.com/aspnetboilerplate/module-zero-core-template/issues/412 while running the tests.

  • Did you install npm dependencies using yarn ?
  • How did you run your tests ?

@ismcagdas ismcagdas transferred this issue from aspnetboilerplate/module-zero-core-template Jun 10, 2019
@ismcagdas ismcagdas added this to the Backlog milestone Jun 10, 2019
@ismcagdas
Copy link
Member

Might be related to dilanx/craco#89

@AllyMurray
Copy link

AllyMurray commented Jun 18, 2019

The above error is not related to that issue, Croco has only been used since the package update. There was however a new issue introduced DocSpring/craco-antd#10

The maintainer is looking for help on that issue, I am going to take a look but I don't have a great deal of experience with webpack and configs.

In the meantime, I have changed the test script back to react-scripts test --env=jsdom this has got it back to this error.

This error is due to abp not being a module, I have changed it to a module and imported it and the test passed.

I don't know what alternative solution there is, ideally, we want to be using the abp package directly from node_modules but as it stands I don't know how we would do that.

@ismcagdas what are your current thoughts on this? I would like to get it sorted out but not sure on the best course of action.

@ismcagdas
Copy link
Member

In Angular version, we were loading abp.js as a vendor script. I'm not sure how to do it in React. The better approach is to write abp.js as a typescript module I guess.

@AllyMurray
Copy link

I just had a look at the Vue project and realised that the React one must be based on that. It also has a lib folder with the abp.js file in it. I haven't run the tests for it but it has the same problem of having to manually update that file.

How do you see this progressing? An independent TS module or a re-write of the current JS file? I would be happy to do it either way.

@ismcagdas
Copy link
Member

@AllyMurray I'm not sure, what do you think ?

@AllyMurray
Copy link

@ismcagdas ideally there wouldn't be two copies of the same code, I don't know how the Angular project is set up but assuming you can easily import the module re-writing the current js file would be the way to go.

This does mean we will have to consider what happens with jQuery, neither the Vue or React projects use jQuery and it's not worth having it as a dependency for such a small amount of code that uses it.

Looking at the current setup for Vue and React they both have the abp.js file copied into a lib folder with all jQuery references removed. Looking at the original file I noticed it does check if jQuery is available before using it and if it's not available it executes equivalent code. The only place this isn't true is when $.Deferred is used. Although it does check for $ before trying to use it, jQuery is passed into the IIFE which produces the error "jQuery is not defined".

So we must either remove jQuery or ensure it works without jQuery when it isn't available. I don't have a strong preference either way however if we were to remove it there would be less code to maintain. If it is removed we would have to replace the $.Deferred functionality.

@ismcagdas ismcagdas modified the milestones: Backlog, v4.8 Jun 21, 2019
@ismcagdas
Copy link
Member

I think it is better to remove JQuery dependency.

@ismcagdas ismcagdas modified the milestones: v4.8, v4.9 Jul 18, 2019
@ismcagdas ismcagdas modified the milestones: v4.9, Backlog Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants