Skip to content

Commit 898fbc1

Browse files
authored
Merge branch 'develop' into mabel/issue-12026-handle-snapshots-in-studio
2 parents 00a488f + 096b756 commit 898fbc1

File tree

9 files changed

+55
-76
lines changed

9 files changed

+55
-76
lines changed

.circleci/src/pipeline/@pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ jobs:
17851785
source ./scripts/ensure-node.sh
17861786
yarn lerna run types
17871787
- sanitize-verify-and-store-mocha-results:
1788-
expectedResultCount: 7
1788+
expectedResultCount: 6
17891789

17901790
verify-release-readiness:
17911791
<<: *defaults

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
- [x] packages/icons ✅ **COMPLETED**
102102
- [x] packages/launcher ✅ **COMPLETED**
103-
- [ ] packages/net-stubbing
103+
- [x] packages/net-stubbing**COMPLETED**
104104
- [x] packages/network ✅ **COMPLETED**
105105
- [x] packages/network-tools ✅ **COMPLETED**
106106
- [ ] packages/packherd-require

packages/net-stubbing/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"check-ts": "tsc --noEmit && yarn -s tslint",
99
"clean-deps": "rimraf node_modules",
1010
"lint": "eslint --ext .ts,.json, .",
11-
"test": "CYPRESS_INTERNAL_ENV=test mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json --exit test/unit/*",
11+
"test": "vitest",
12+
"test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0",
13+
"test-watch": "vitest watch",
1214
"tslint": "tslint --config ../ts/tslint.json --project ."
1315
},
1416
"dependencies": {
@@ -26,8 +28,7 @@
2628
"@packages/server": "0.0.0-development",
2729
"@packages/telemetry": "0.0.0-development",
2830
"@types/mime": "^3.0.1",
29-
"chai": "4.2.0",
30-
"mocha": "7.1.2"
31+
"vitest": "^3.2.4"
3132
},
3233
"files": [
3334
"lib"

packages/net-stubbing/test/unit/driver-events-spec.ts renamed to packages/net-stubbing/test/unit/driver-events.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { describe, it, expect } from 'vitest'
12
import {
23
_restoreMatcherOptionsTypes,
34
} from '../../lib/server/driver-events'
4-
import { expect } from 'chai'
55

66
describe('driver events', function () {
7-
context('._restoreMatcherOptionsTypes', function () {
7+
describe('._restoreMatcherOptionsTypes', function () {
88
it('rehydrates regexes properly', function () {
99
const { url } = _restoreMatcherOptionsTypes({
1010
url: {
@@ -13,8 +13,8 @@ describe('driver events', function () {
1313
},
1414
})
1515

16-
expect(url).to.be.instanceOf(RegExp)
17-
.and.include({
16+
expect(url).toBeInstanceOf(RegExp)
17+
expect(url).toMatchObject({
1818
flags: 'gim',
1919
source: 'aaa',
2020
})

packages/net-stubbing/test/unit/intercepted-request-spec.ts renamed to packages/net-stubbing/test/unit/intercepted-request.spec.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import chai, { expect } from 'chai'
1+
import { describe, it, expect, vi } from 'vitest'
22
import _ from 'lodash'
3-
import sinon from 'sinon'
4-
import sinonChai from 'sinon-chai'
53
import { InterceptedRequest } from '../../lib/server/intercepted-request'
64
import { state as NetStubbingState } from '../../lib/server/state'
75

8-
chai.use(sinonChai)
9-
106
describe('InterceptedRequest', () => {
11-
context('handleSubscriptions', () => {
7+
describe('handleSubscriptions', () => {
128
it('handles subscriptions as expected', async () => {
139
const socket = {
14-
toDriver: sinon.stub(),
10+
toDriver: vi.fn(),
1511
}
1612
const state = NetStubbingState()
1713
const interceptedRequest = new InterceptedRequest({
@@ -45,10 +41,10 @@ describe('InterceptedRequest', () => {
4541

4642
const data = { foo: 'bar' }
4743

48-
socket.toDriver.callsFake((eventName, subEventName, frame) => {
49-
expect(eventName).to.eq('net:stubbing:event')
50-
expect(subEventName).to.eq('before:request')
51-
expect(frame).to.deep.include({
44+
socket.toDriver.mockImplementation((eventName, subEventName, frame) => {
45+
expect(eventName).toEqual('net:stubbing:event')
46+
expect(subEventName).toEqual('before:request')
47+
expect(frame).toMatchObject({
5248
subscription: {
5349
eventName: 'before:request',
5450
await: true,
@@ -65,12 +61,12 @@ describe('InterceptedRequest', () => {
6561
mergeChanges: _.merge,
6662
})
6763

68-
expect(socket.toDriver).to.be.calledTwice
64+
expect(socket.toDriver).toHaveBeenCalledTimes(2)
6965
})
7066

7167
it('ignores disabled subscriptions', async () => {
7268
const socket = {
73-
toDriver: sinon.stub(),
69+
toDriver: vi.fn(),
7470
}
7571
const state = NetStubbingState()
7672
const interceptedRequest = new InterceptedRequest({
@@ -99,10 +95,10 @@ describe('InterceptedRequest', () => {
9995

10096
const data = { foo: 'bar' }
10197

102-
socket.toDriver.callsFake((eventName, subEventName, frame) => {
103-
expect(eventName).to.eq('net:stubbing:event')
104-
expect(subEventName).to.eq('before:request')
105-
expect(frame).to.deep.include({
98+
socket.toDriver.mockImplementation((eventName, subEventName, frame) => {
99+
expect(eventName).toEqual('net:stubbing:event')
100+
expect(subEventName).toEqual('before:request')
101+
expect(frame).toMatchObject({
106102
subscription: {
107103
eventName: 'before:request',
108104
await: true,
@@ -119,7 +115,7 @@ describe('InterceptedRequest', () => {
119115
mergeChanges: _.merge,
120116
})
121117

122-
expect(socket.toDriver).to.be.calledOnce
118+
expect(socket.toDriver).toHaveBeenCalledOnce()
123119
})
124120
})
125121
})

packages/net-stubbing/test/unit/route-matching-spec.ts renamed to packages/net-stubbing/test/unit/route-matching.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { describe, it, expect } from 'vitest'
12
import {
23
_doesRouteMatch,
34
_getMatchableForRequest,
45
getRoutesForRequest,
56
} from '../../lib/server/route-matching'
67
import { RouteMatcherOptions } from '../../lib/types'
7-
import { expect } from 'chai'
88
import { CypressIncomingRequest } from '@packages/proxy'
99
import { BackendRoute } from '../../lib/server/types'
1010

1111
describe('intercept-request', function () {
12-
context('._getMatchableForRequest', function () {
12+
describe('._getMatchableForRequest', function () {
1313
it('converts a fully-fledged req into a matchable shape', function () {
1414
const req = {
1515
headers: {
@@ -23,7 +23,7 @@ describe('intercept-request', function () {
2323

2424
const matchable = _getMatchableForRequest(req)
2525

26-
expect(matchable).to.deep.eq({
26+
expect(matchable).toEqual({
2727
auth: {
2828
username: 'foo',
2929
password: 'bar',
@@ -43,15 +43,15 @@ describe('intercept-request', function () {
4343
})
4444
})
4545

46-
context('._doesRouteMatch', function () {
46+
describe('._doesRouteMatch', function () {
4747
const tryMatch = (req: Partial<CypressIncomingRequest>, matcher: RouteMatcherOptions, expected = true) => {
4848
req = {
4949
method: 'GET',
5050
headers: {},
5151
...req,
5252
}
5353

54-
expect(_doesRouteMatch(matcher, req as CypressIncomingRequest)).to.eq(expected)
54+
expect(_doesRouteMatch(matcher, req as CypressIncomingRequest)).toEqual(expected)
5555
}
5656

5757
it('matches exact URL', function () {
@@ -172,7 +172,7 @@ describe('intercept-request', function () {
172172
})
173173
})
174174

175-
context('.getRoutesForRequest', function () {
175+
describe('.getRoutesForRequest', function () {
176176
it('matches middleware, then handlers', function () {
177177
const routes: Partial<BackendRoute>[] = [
178178
{
@@ -216,7 +216,7 @@ describe('intercept-request', function () {
216216
e.push(route.id)
217217
}
218218

219-
expect(e).to.deep.eq(['1', '3', '4', '2'])
219+
expect(e).toEqual(['1', '3', '4', '2'])
220220
})
221221

222222
it('yields identical matches', function () {
@@ -255,7 +255,7 @@ describe('intercept-request', function () {
255255
matchedRouteIds.push(route.id)
256256
}
257257

258-
expect(matchedRouteIds).to.deep.eq(['1', '1'])
258+
expect(matchedRouteIds).toEqual(['1', '1'])
259259
})
260260
})
261261
})

packages/net-stubbing/test/unit/util-spec.ts renamed to packages/net-stubbing/test/unit/util.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { describe, it, expect } from 'vitest'
12
import { getBodyEncoding, parseContentType } from '../../lib/server/util'
2-
import { expect } from 'chai'
33
import { join } from 'path'
44
import { readFileSync } from 'fs'
55

@@ -10,7 +10,7 @@ describe('net-stubbing util', () => {
1010
it('returns application/json', () => {
1111
const str = JSON.stringify({ foo: 'bar' })
1212

13-
expect(parseContentType(str)).to.eq('application/json')
13+
expect(parseContentType(str)).toEqual('application/json')
1414
})
1515

1616
it('returns text/html', () => {
@@ -20,23 +20,23 @@ describe('net-stubbing util', () => {
2020
</html>\
2121
`
2222

23-
expect(parseContentType(str)).to.eq('text/html')
23+
expect(parseContentType(str)).toEqual('text/html')
2424
})
2525

2626
it('returns text/plain', () => {
2727
const str = 'foobar<p>baz'
2828

29-
expect(parseContentType(str)).to.eq('text/plain')
29+
expect(parseContentType(str)).toEqual('text/plain')
3030
})
3131

3232
it('returns text/plain by default', () => {
33-
expect(parseContentType()).to.eq('text/plain')
33+
expect(parseContentType()).toEqual('text/plain')
3434
})
3535
})
3636

37-
context('getBodyEncoding', () => {
37+
describe('getBodyEncoding', () => {
3838
it('returns null without data', () => {
39-
expect(getBodyEncoding(null)).to.equal(null)
39+
expect(getBodyEncoding(null)).toBeNull()
4040

4141
const emptyRequest = {
4242
body: null,
@@ -46,7 +46,7 @@ describe('net-stubbing util', () => {
4646
httpVersion: '1.1',
4747
}
4848

49-
expect(getBodyEncoding(emptyRequest)).to.equal(null)
49+
expect(getBodyEncoding(emptyRequest)).toBeNull()
5050
})
5151

5252
it('returns utf8', () => {
@@ -70,7 +70,7 @@ describe('net-stubbing util', () => {
7070
httpVersion: '1.1',
7171
}
7272

73-
expect(getBodyEncoding(req), contentType).to.equal('utf8')
73+
expect(getBodyEncoding(req), contentType).toEqual('utf8')
7474
})
7575
})
7676

@@ -83,7 +83,7 @@ describe('net-stubbing util', () => {
8383
httpVersion: '1.1',
8484
}
8585

86-
expect(getBodyEncoding(req), 'text').to.equal('utf8')
86+
expect(getBodyEncoding(req), 'text').toEqual('utf8')
8787
})
8888

8989
it('falls back to inspecting bytes to find image', () => {
@@ -95,7 +95,7 @@ describe('net-stubbing util', () => {
9595
httpVersion: '1.1',
9696
}
9797

98-
expect(getBodyEncoding(req), 'image').to.equal('binary')
98+
expect(getBodyEncoding(req), 'image').toEqual('binary')
9999
})
100100
})
101101
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
env: {
6+
CYPRESS_INTERNAL_ENV: 'test',
7+
},
8+
include: ['test/**/*.spec.ts'],
9+
globals: true,
10+
environment: 'node',
11+
},
12+
})

yarn.lock

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23966,36 +23966,6 @@ mocha@7.1.0:
2396623966
yargs-parser "13.1.1"
2396723967
yargs-unparser "1.6.0"
2396823968

23969-
mocha@7.1.2:
23970-
version "7.1.2"
23971-
resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.1.2.tgz#8e40d198acf91a52ace122cd7599c9ab857b29e6"
23972-
integrity sha512-o96kdRKMKI3E8U0bjnfqW4QMk12MwZ4mhdBTf+B5a1q9+aq2HRnj+3ZdJu0B/ZhJeK78MgYuv6L8d/rA5AeBJA==
23973-
dependencies:
23974-
ansi-colors "3.2.3"
23975-
browser-stdout "1.3.1"
23976-
chokidar "3.3.0"
23977-
debug "3.2.6"
23978-
diff "3.5.0"
23979-
escape-string-regexp "1.0.5"
23980-
find-up "3.0.0"
23981-
glob "7.1.3"
23982-
growl "1.10.5"
23983-
he "1.2.0"
23984-
js-yaml "3.13.1"
23985-
log-symbols "3.0.0"
23986-
minimatch "3.0.4"
23987-
mkdirp "0.5.5"
23988-
ms "2.1.1"
23989-
node-environment-flags "1.0.6"
23990-
object.assign "4.1.0"
23991-
strip-json-comments "2.0.1"
23992-
supports-color "6.0.0"
23993-
which "1.3.1"
23994-
wide-align "1.1.3"
23995-
yargs "13.3.2"
23996-
yargs-parser "13.1.2"
23997-
yargs-unparser "1.6.0"
23998-
2399923969
mocha@7.2.0, mocha@^7.1.0:
2400023970
version "7.2.0"
2400123971
resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.2.0.tgz#01cc227b00d875ab1eed03a75106689cfed5a604"

0 commit comments

Comments
 (0)