Skip to content

Commit 191c8fe

Browse files
committed
chore: start launcher vitest conversion and conver browsers spec to vitest
1 parent b1ec294 commit 191c8fe

File tree

8 files changed

+158
-167
lines changed

8 files changed

+158
-167
lines changed

guides/esm-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa
100100
- [x] packages/electron ✅ **COMPLETED**
101101
- [ ] packages/https-proxy
102102
- [ ] packages/icons
103-
- [ ] packages/launcher
103+
- [x] packages/launcher**COMPLETED**
104104
- [ ] packages/net-stubbing
105105
- [x] packages/network ✅ **COMPLETED**
106106
- [ ] packages/packherd-require

packages/launcher/__snapshots__/browsers_spec.ts.js

Lines changed: 0 additions & 123 deletions
This file was deleted.

packages/launcher/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .",
1212
"size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"cli/${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
1313
"test": "yarn test-unit",
14-
"test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json",
14+
"test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0",
15+
"test-unit": "vitest run",
1516
"tslint": "tslint --config ../ts/tslint.json --project ."
1617
},
1718
"dependencies": {
@@ -29,13 +30,9 @@
2930
"@packages/data-context": "0.0.0-development",
3031
"@packages/ts": "0.0.0-development",
3132
"@packages/types": "0.0.0-development",
32-
"chai": "3.5.0",
33-
"chai-as-promised": "7.1.1",
34-
"mocha": "3.5.3",
3533
"mock-fs": "5.4.0",
36-
"sinon": "^10.0.0",
37-
"sinon-chai": "3.7.0",
38-
"typescript": "~5.4.5"
34+
"typescript": "~5.4.5",
35+
"vitest": "^3.2.4"
3936
},
4037
"files": [
4138
"index.js",

packages/launcher/test/spec_helper.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`browsers > returns the expected list of browsers 1`] = `
4+
[
5+
{
6+
"binary": [
7+
"google-chrome",
8+
"chrome",
9+
"google-chrome-stable",
10+
],
11+
"channel": "stable",
12+
"displayName": "Chrome",
13+
"family": "chromium",
14+
"name": "chrome",
15+
"validator": [Function],
16+
"versionRegex": /Google Chrome\\(\\?! for Testing\\) \\(\\\\S\\+\\)/m,
17+
},
18+
{
19+
"binary": "google-chrome-beta",
20+
"channel": "beta",
21+
"displayName": "Chrome Beta",
22+
"family": "chromium",
23+
"name": "chrome",
24+
"versionRegex": /Google Chrome \\(\\\\S\\+\\) beta/m,
25+
},
26+
{
27+
"binary": "google-chrome-canary",
28+
"channel": "canary",
29+
"displayName": "Chrome Canary",
30+
"family": "chromium",
31+
"name": "chrome",
32+
"versionRegex": /Google Chrome Canary \\(\\\\S\\+\\)/m,
33+
},
34+
{
35+
"binary": "chrome",
36+
"channel": "stable",
37+
"displayName": "Chrome for Testing",
38+
"family": "chromium",
39+
"name": "chrome-for-testing",
40+
"versionRegex": /Google Chrome for Testing \\(\\\\S\\+\\)/m,
41+
},
42+
{
43+
"binary": [
44+
"chromium-browser",
45+
"chromium",
46+
],
47+
"channel": "stable",
48+
"displayName": "Chromium",
49+
"family": "chromium",
50+
"name": "chromium",
51+
"versionRegex": /Chromium \\(\\\\S\\+\\)/m,
52+
},
53+
{
54+
"binary": "firefox",
55+
"channel": "stable",
56+
"displayName": "Firefox",
57+
"family": "firefox",
58+
"name": "firefox",
59+
"validator": [Function],
60+
"versionRegex": /\\^Mozilla Firefox \\(\\[\\^\\\\sab\\]\\+\\)\\$/m,
61+
},
62+
{
63+
"binary": [
64+
"firefox-developer-edition",
65+
"firefox",
66+
],
67+
"channel": "dev",
68+
"displayName": "Firefox Developer Edition",
69+
"family": "firefox",
70+
"name": "firefox",
71+
"validator": [Function],
72+
"versionRegex": /\\^Mozilla Firefox \\(\\\\S\\+b\\\\S\\*\\)\\$/m,
73+
},
74+
{
75+
"binary": [
76+
"firefox-nightly",
77+
"firefox-trunk",
78+
],
79+
"channel": "nightly",
80+
"displayName": "Firefox Nightly",
81+
"family": "firefox",
82+
"name": "firefox",
83+
"validator": [Function],
84+
"versionRegex": /\\^Mozilla Firefox \\(\\\\S\\+a\\\\S\\*\\)\\$/m,
85+
},
86+
{
87+
"binary": [
88+
"edge",
89+
"microsoft-edge",
90+
],
91+
"channel": "stable",
92+
"displayName": "Edge",
93+
"family": "chromium",
94+
"name": "edge",
95+
"versionRegex": /Microsoft Edge \\(\\\\S\\+\\)/im,
96+
},
97+
{
98+
"binary": [
99+
"edge-beta",
100+
"microsoft-edge-beta",
101+
],
102+
"channel": "beta",
103+
"displayName": "Edge Beta",
104+
"family": "chromium",
105+
"name": "edge",
106+
"versionRegex": /Microsoft Edge\\.\\+\\?\\(\\\\S\\*\\(\\?= beta\\)\\|\\(\\?<=beta \\)\\\\S\\*\\)/im,
107+
},
108+
{
109+
"binary": [
110+
"edge-canary",
111+
"microsoft-edge-canary",
112+
],
113+
"channel": "canary",
114+
"displayName": "Edge Canary",
115+
"family": "chromium",
116+
"name": "edge",
117+
"versionRegex": /Microsoft Edge\\.\\+\\?\\(\\\\S\\*\\(\\?= canary\\)\\|\\(\\?<=canary \\)\\\\S\\*\\)/im,
118+
},
119+
{
120+
"binary": [
121+
"edge-dev",
122+
"microsoft-edge-dev",
123+
],
124+
"channel": "dev",
125+
"displayName": "Edge Dev",
126+
"family": "chromium",
127+
"name": "edge",
128+
"versionRegex": /Microsoft Edge\\.\\+\\?\\(\\\\S\\*\\(\\?= dev\\)\\|\\(\\?<=dev \\)\\\\S\\*\\)/im,
129+
},
130+
]
131+
`;

packages/launcher/test/unit/browsers_spec.ts renamed to packages/launcher/test/unit/browsers.spec.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
import { describe, it, expect } from 'vitest'
12
import _ from 'lodash'
23
import { knownBrowsers } from '../../lib/known-browsers'
3-
import { expect } from 'chai'
4-
const snapshot = require('snap-shot-it')
54

65
describe('browsers', () => {
76
it('returns the expected list of browsers', () => {
8-
snapshot(knownBrowsers)
7+
expect(knownBrowsers).toMatchSnapshot()
98
})
109

1110
// https://github.com/cypress-io/cypress/issues/6669
1211
it('exports multiline versionRegexes', () => {
1312
expect(_.every(knownBrowsers.map(({ versionRegex }) => {
1413
return versionRegex.multiline
15-
}))).to.be.true
14+
}))).toBe(true)
1615
})
1716

1817
describe('browser.validator', () => {
@@ -21,7 +20,7 @@ describe('browsers', () => {
2120
path: '/path/to/firefox',
2221
}
2322

24-
context('validator defined', () => {
23+
describe('validator defined', () => {
2524
it('when conditions met: marks browser as not supported and generates warning message', () => {
2625
const foundBrowser = {
2726
...firefoxBrowser,
@@ -43,8 +42,8 @@ describe('browsers', () => {
4342

4443
const result = foundBrowser.validator(foundBrowser, 'win32')
4544

46-
expect(result.isSupported).to.be.false
47-
expect(result.warningMessage).to.contain('Cypress does not support running Firefox version 101 on Windows due to a blocking bug in Firefox.')
45+
expect(result.isSupported).toBe(false)
46+
expect(result.warningMessage).toContain('Cypress does not support running Firefox version 101 on Windows due to a blocking bug in Firefox.')
4847
})
4948

5049
it('when conditions not met: marks browser as not supported and generates warning message', () => {
@@ -68,8 +67,8 @@ describe('browsers', () => {
6867

6968
const result = foundBrowser.validator(foundBrowser, 'win32')
7069

71-
expect(result.isSupported).to.be.true
72-
expect(result.warningMessage).to.be.undefined
70+
expect(result.isSupported).toBe(true)
71+
expect(result.warningMessage).toBeUndefined()
7372
})
7473

7574
describe('firefox validation', () => {
@@ -85,8 +84,8 @@ describe('browsers', () => {
8584
displayName: 'Firefox',
8685
})
8786

88-
expect(result.isSupported).to.be.false
89-
expect(result.warningMessage).to.equal('Cypress does not support running Firefox version 134 due to lack of WebDriver BiDi support. To use Firefox with Cypress, install version 135 or newer.')
87+
expect(result.isSupported).toBe(false)
88+
expect(result.warningMessage).toEqual('Cypress does not support running Firefox version 134 due to lack of WebDriver BiDi support. To use Firefox with Cypress, install version 135 or newer.')
9089
})
9190
})
9291
})

packages/launcher/vitest.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['test/**/*.spec.ts'],
6+
globals: true,
7+
environment: 'node',
8+
},
9+
})

0 commit comments

Comments
 (0)