Skip to content

Commit 6601c42

Browse files
committed
Add basic DataContext unit test
1 parent 155fb32 commit 6601c42

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
exports['@packages/data-context initializeData should initialize 1'] = {
2+
"shellConfig": {
3+
"launchOptions": {},
4+
"launchArgs": {},
5+
"appApi": {},
6+
"authApi": {},
7+
"projectApi": {}
8+
},
9+
"config": {
10+
"launchOptions": {},
11+
"launchArgs": {},
12+
"appApi": {},
13+
"authApi": {},
14+
"projectApi": {}
15+
},
16+
"_coreData": {
17+
"baseError": null,
18+
"dev": {
19+
"refreshState": null
20+
},
21+
"app": {
22+
"activeTestingType": null,
23+
"navItem": "settings",
24+
"browsers": {},
25+
"projects": [],
26+
"activeProject": null,
27+
"isInGlobalMode": false,
28+
"isAuthBrowserOpened": false
29+
},
30+
"wizard": {
31+
"chosenTestingType": null,
32+
"chosenBundler": null,
33+
"chosenFramework": null,
34+
"chosenLanguage": "js",
35+
"chosenManualInstall": false,
36+
"currentStep": "welcome",
37+
"allBundlers": [
38+
{
39+
"type": "webpack",
40+
"name": "Webpack",
41+
"package": "@cypress/webpack-dev-server"
42+
},
43+
{
44+
"type": "vite",
45+
"name": "Vite",
46+
"package": "@cypress/vite-dev-server"
47+
}
48+
],
49+
"history": [
50+
"welcome"
51+
],
52+
"chosenBrowser": null
53+
},
54+
"user": null,
55+
"electron": {
56+
"browserWindow": null
57+
}
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
import { expect } from 'chai'
2+
import { DataContext } from '@packages/data-context'
3+
import snapshot from 'snap-shot-it'
24

3-
describe('@packages/data-context unit', () => {
4-
it('has a sample test', () => {
5-
expect(1).to.eq(1)
5+
const makeDataContext = (options) => {
6+
return new DataContext({
7+
launchOptions: {},
8+
launchArgs: {},
9+
appApi: {
10+
getBrowsers: () => ({}),
11+
},
12+
authApi: {},
13+
projectApi: {
14+
getProjectRootsFromCache: () => ([]),
15+
},
16+
...options,
17+
})
18+
}
19+
20+
describe('@packages/data-context', () => {
21+
describe('initializeData', () => {
22+
it('should initialize', async () => {
23+
const context = makeDataContext()
24+
25+
await context.initializeData()
26+
snapshot(context)
27+
})
28+
29+
it('should skip first wizard step when given a testingType', async () => {
30+
const context = makeDataContext({
31+
launchArgs: {
32+
testingType: 'e2e',
33+
},
34+
})
35+
36+
await context.initializeData()
37+
expect(context._coreData.wizard).to.contain({
38+
chosenTestingType: 'e2e',
39+
currentStep: 'initializePlugins',
40+
})
41+
})
642
})
743
})

0 commit comments

Comments
 (0)