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

No npm "test" script defined. You must define a "test" script i #1413

Open
ejgutierrez74 opened this issue May 20, 2024 · 3 comments
Open

No npm "test" script defined. You must define a "test" script i #1413

ejgutierrez74 opened this issue May 20, 2024 · 3 comments

Comments

@ejgutierrez74
Copy link


Steps to Reproduce

1 - Install : npm install -g npm-check-updates

2 - Run: ncu --doctor -u

3 - Error
eduardo@MiPcLinux:~/Descargas/workshop-react$ ncu --doctor -u
No npm "test" script defined. You must define a "test" script in the "scripts" section of your package.json to use --doctor.

eduardo@MiPcLinux:~/Descargas/workshop-react$ ncu --doctor -u
Running tests before upgrading
npm install
npm run test

> [email protected] test
> echo "Error: no test specified" && exit 1

Error: no test specified
Tests failed before we even got started!
eduardo@MiPcLinux:~/Descargas/workshop-react$ ncu --doctor -u
Missing or invalid package.json
eduardo@MiPcLinux:~/Descargas/workshop-react$ ncu --doctor -u
Missing or invalid package.json

When installing should address this or give some example of tests.
Thanks to copilot i added this test ( but dont know if its correct or what is supposed to do the test script as no info is provided). For example i added and exit 1 to the echo, but it still gave me an error. So i made a test script with only one echo as you can see:

 "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview",
    "test": "echo \"Error: no test specified\""
  },
@raineorshine
Copy link
Owner

Doctor mode only works if you have automated tests in your project. If you don't have automated tests, then there is nothing to test the upgrades against. You should just use ncu -u.

@ejgutierrez74
Copy link
Author

ejgutierrez74 commented May 20, 2024

But id like to test if the upgrade wont be messing things or arrive at some incompatible libraries... for example i dont know if there could be any problem between react-chatbotify and es_lint latest versions... Thats the reason why i want to use doctor.

In python you have the option --test to install or upgrade libraries. It makes all the things but the library is not really installed... then if you dont have any problem you can install safety the upgrade or new library without that parameter.

Then i leave a feature request: create a test or use doctor without tests, just to be sure that the process of upgrading is not going to put the system in not desired state ( buggy, incompatible, stop working...)

As i read if i use directly ncu -u...it would just upgrade all the libraries without any tests...so that can lead my system to be unstable or stop working..then going back could be no easy....Perhaps im missing something.

Thanks for your help

@raineorshine
Copy link
Owner

raineorshine commented May 20, 2024

The closest thing to what you are looking for is --peer which only upgrades dependencies that meet peerDependency requirements. It's still up to the individual packages to specify peerDepedencies.

I'm not aware of any general compatibility test as you describe, though I assume that npm or yarn does some checks on install. This is another good reason for project-specific unit tests. If you have automated test coverage of the key functionality of your app or website, then any compatibility issue with installs will fail the tests.

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

2 participants