Cypress - install it on empty project - javascript

I am trying to install cypress on an empty project. However, cypress is not installed in the package.js file and cypress is not included on the project. How can I make it work? I cannot install cypress as part of the development project, so i am trying to create a separate test automation project with cypress.

Steps to install cypress:
Step 1: Create your project folder, go inside the folder from the terminal using cd folder_path/folder_name and run npm init. This will create your package.json file inside your project folder. You can do this in a sperate project or create some folder in your development project and do it there as well.
Step 2: Now, Run the command npm install cypress --save-dev. This will add the cypress as a dev dependency inside your package.json file. Once you have successfully installed this, you should see one more file package-lock.json and an folder node_modules being created
Step 3: Run the command node_modules/.bin/cypress open or node_modules/.bin/cypress run to run cypress.

You need to add --save or --save-dev to save it to package.json file. eg: npm install cypress --save. https://docs.npmjs.com/cli/v6/commands/npm-install

Normally you install Cypress into your dev project, but I see you can't do that.
Go to https://www.cypress.io, middle of the page is Download now.
After downloading, unzip to a folder, open bash or cmd prompt in that folder and type Cypress.
You get some warnings about installing into your project being preferred, but it works fine.
There's a To get started... box on the runner. Choose the same folder, and Cypress will set up the testing folder structure
/cypress
/integration
/examples -- lots of sample tests here
/support
/plugins
/fixtures
etc

Related

Can I run git clone via an NPX tool

Im in the process of building a custom NPX tool which will add my custom npm package into a local hosted server,
I have as of right now a template of the structure id like to replicate when other users run my NPX command, something along the lines of
src
index.js
build
built_js.js
styles
styles.css
I understand when it comes to npm packages ill have to run these commands separately which is fine but im wondering how i can rebuild this directory on command npx create-my-app
yes you can!
try to use this package for it:
https://www.npmjs.com/package/create-clone

Deploying a NestJs project on a single board computer (Raspberry or similar)

even if it seems a simple task I'm having some trouble finding a solution. I know that with Nest CLI I can use the command "nest build" in order to create a dist folder that contains the production files of my project.
The problem is when I move the folder on my Raspberry and i try to run the project with the command "node dist/main" following NestJs instructions. Nothing starts because node says that it cannot find #nestjs/core and other modules.
I did't find nothing clear in the official guide about deploying the app, so my question is: what do I need to move onto my rasperry in addition to dist folder? Do I need to reinstall all node_modules folder or it's possible to have a running project without have to reinstall 800Mb of modules?
Yes you need to run yarn or npm install on your production environment, as your dist folder only contains your own code.
Because unlike compiled language like Golang where all dependencies are bundled and compiled in you executable file, Javascript bundlers don't. Your bundled code in dist still contains require or import statement to get dependencies from node_modules.
You can also run npm prune --production to remove any developpement dependencies and thus reduce the size of your node_modules folder. (I believe that yarn does it by default.)

Getting Node Module Error (Cannot find module)

I am learning the Automated tests by using selenium web driver + Javascript and node.js.
Everything is working fine when I ran that script.js from the Visual Studio code terminal(by using node main.js)
Problem
I want to schedule this script in the scheduler which automatically tests the login functionality. But when I try to run it from the task scheduler then it gives Error: Cannot find module
Does anybody know how to get rid of this.
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. ... or delete the node_modules folder and package-lock. json file and re-install it again using the npm install command.
rm -rf node_modules package-lock.json

'vue' is not recognized as an internal or external command

everything was installed correctly. but whenever I try to create project, it says "'vue' is not recognized as an internal or external command". I installed and re-installed but didn't work. npm was also added to environmental variable path.
C:\Users\touha\Desktop>npm list -g --depth=0
C:\Users\touha\.npm-packages
`-- #vue/cli#3.8.2
C:\Users\touha\Desktop>vue ui
'vue' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\touha\Desktop>
Locate vue.cmd and add its location to your PATH
It is added to package manager(npm or yarn) installation. So you may find it at following locations
YARN
C:\Users{YourAccount}\AppData\Local\Yarn\bin
NPM
C:\Users{YourAccount}\AppData\Roaming\npm
just open PowerShell and run: npm install -g #vue/cli
Addition: If setting the path variable and reinstalling #vue/cli does not work, using the node.js command prompt instead might solve the issue.
It seems vue isn't been installed globally for some reasons.
This is the step I followed to solve mine:
Firstly, create your desired project folder (say "Vue Project"). This is where you want to create a vue project.
Then create a "node_modules" folder in the Vue Project folder
Then go to your system npm folder C:\Users{YourAccount}\AppData\Roaming\npm
You will see three different "vue" files. Copy them and paste in the Vue Project Folder you created.
Go back to C:\Users{YourAccount}\AppData\Roaming\npm and enter the node_modules folder. You'll see a "#vue" folder. Copy this, and paste it in the node_modules folder you created in the Vue Project Folder.
You can now head back to the CLI and create your project using "vue create my-vue-project" where my-vue-project is your desired vue project name.
You can try this way it worked for me
go to the location of your yarn or npm mine is C:\Users\TED\AppData\Local\Yarn\bin for Yarn
C:\Users\TED\AppData\Local\Npm\bin for Npm users
TED will be replaced by your user name
then copy and add it to your system environment variable
Note in case you don't find AppData make sure you have view hidden file checked
I am using Yarn to install #vue/cli.
The way I solve it is via the following steps
Locate your global installed vue.cmd location
Add the vue.cmd directory into System variable Env. For myself, the path is C:\Users{MyAccount}\AppData\Local\Yarn\.bin
what worked for me:
In a powershell :
npm install vue
npm install -g #vue/cli
C:\Users\{USER}\AppData\Roaming\npm\vue.cmd create {NAME}
if you got this error most probably chance package not installed completely
check-in C:\Users\dev\AppData\Roaming\npm
if you had not found the package under this folder then re-run your command
Run command prompt as administrator
Run setx /M path "%path%;%appdata%\npm
Restart the command prompt
Now create the Vue project

how do i run jest test on a node_modules folder in react

I have added my own another project as a dependency. now it's on the node_modules folder now
how do I run test file on that folder when running the npm test
I don't know what your needs are but this is wrong.
If you want your project to be a dependency there are other safest ways to do that.
For example, with yarn, you can install a package from your computer as a dependency.
Consider the following example: you have your main-project, in which you want to include your sub-project.
So, in your main-project directory you can run yarn add ../path/to/sub-project and yarn will copy the code of your sub-project into the main-project. In this way you can keep the code splitted in two different reporitories.
A better way, if your sub-project is on github, bitbucket or whatever, is to give to yarn the url of your repo.
Yarn will automatically clone the repo into your node_modules every time that you'll run yarn. You can also specify a specific commit to use.
Read more about that in the yarn documentation.

Categories

Resources