or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
# Setting up the Cypress GUI in WSL2 Ubuntu (20.04) for Windows 10
Setting up the Cypress GUI in WSL2 Ubuntu (20.04) for Windows 10
Adapted and tested 3/10/21
First, check that you're actually running WSL2. In a Windows 10 command prompt/PowerShell (not in a linux terminal):
wsl -l -v
For this guide, you should be seeing
NAME: Ubuntu, STATE: Running, VERSION: 2
.You'll also need Node. To check if you've already got it, again in a command prompt:
node --version
Let's create a "project" to install cypress in. In your linux terminal:
mkdir cypress-setup-test
cd cypress-setup-test
npm init
npm i cypress --save-dev
Let's add a convenience command to package.json:
code .
Open
package.json
in VS Code and add this to the scripts object:This allows us to open Cypress tests by simply using
npm t open
.Trying to open Cypress will likely result in an error as you are missing stuff. Go to the cypress docs and run the listed command there to install the required dependencies. (Might need to stick
sudo
in front of the command.)Now if you try to open it (and the correct dependencies are installed), it won't bring up the Cypress GUI. WSL2 doesn't have the ability to display graphic interfaces, but we can ask Windows 10 to display them for us. We do that using an X Server. There are a number of them, but we'll use VcXsrv here. Go ahead and download and install VcXsrv.
Now we have to make sure graphical interfaces launched from WSL2 know what local ip WSL2 is at.
Open a new linux terminal tab and use the following commands:
In VS Code, open the
.bashrc
file.Add the following to the top (important that it is the very top) of the file:
Next, we'll have to enable D-Bus so these applications can exchange messages.
Add the following underneath the place where we set the DISPLAY environment variable:
Close all linux terminals.
Launch a linux terminal. From now on, you may be asked for your password when you open a linux terminal window/tab (I think this is because linux is running the
sudo
command we just set above on launch).Now launch the X Server in Windows (if you're using VcXsrv, look for XLaunch).
You can accept the defaults for Display settings and Client startup, but under Extra settings make sure to check the Disable access control checkbox.
In the Windows security alert that comes up first time XLaunch is launched, allow public & private networks.
Finally, check this has all worked by trying to open Cypress again with
npm t open
🤞Whenever you want to open cypress, you'll need to make sure XLaunch is running in Windows first with the "Disable access control" checked.
When using cypress, best to launch it in a separate linux tab from the one you want to use for navigation/other stuff as opening cypress this way locks up your terminal and fills it with error messages (that I think are fine) and console logs.
It seems that when you make changes to your tests you have to reopen a test window.
Adapted from: https://wilcovanes.ch/articles/setting-up-the-cypress-gui-in-wsl2-ubuntu-for-windows-10/