mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-21 23:59:33 -05:00
refactor: remove __fakeInstalledPackagesForTesting (#20529)
* refactor: remove __fakeInstalledPackagesForTesting, use sinon.stub * make tests pass (avoid double mocking) Co-authored-by: ElevateBart <ledouxb@gmail.com> Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
This commit is contained in:
@@ -70,7 +70,6 @@ export interface WizardDataShape {
|
||||
detectedLanguage: NexusGenEnums['CodeLanguageEnum'] | null
|
||||
detectedBundler: Bundler | null
|
||||
detectedFramework: typeof FRONTEND_FRAMEWORKS[number]['type'] | null
|
||||
__fakeInstalledPackagesForTesting: string[] | null
|
||||
}
|
||||
|
||||
export interface MigrationDataShape{
|
||||
@@ -168,7 +167,6 @@ export function makeCoreData (modeOptions: Partial<AllModeOptions> = {}): CoreDa
|
||||
chosenManualInstall: false,
|
||||
detectedBundler: null,
|
||||
detectedFramework: null,
|
||||
__fakeInstalledPackagesForTesting: null,
|
||||
detectedLanguage: null,
|
||||
},
|
||||
migration: {
|
||||
|
||||
@@ -66,10 +66,6 @@ export class WizardDataSource {
|
||||
}
|
||||
|
||||
async installedPackages (): Promise<string[]> {
|
||||
if (this.ctx.coreData.wizard.__fakeInstalledPackagesForTesting) {
|
||||
return this.ctx.coreData.wizard.__fakeInstalledPackagesForTesting
|
||||
}
|
||||
|
||||
const packagesInitial = await this.packagesToInstall() || []
|
||||
|
||||
if (!this.ctx.currentProject) {
|
||||
|
||||
@@ -2,12 +2,10 @@ import { BUNDLERS, FRONTEND_FRAMEWORKS, AllPackagePackages } from '@packages/sca
|
||||
import { CODE_LANGUAGES } from '@packages/types/src'
|
||||
|
||||
function fakeInstalledDeps () {
|
||||
cy.withCtx(async (ctx) => {
|
||||
cy.withCtx(async (ctx, o) => {
|
||||
const deps = (await ctx.wizard.packagesToInstall() ?? []).map((x) => x.package)
|
||||
|
||||
ctx.update((coreData) => {
|
||||
coreData.wizard.__fakeInstalledPackagesForTesting = deps
|
||||
})
|
||||
o.sinon.stub(ctx.wizard, 'installedPackages').resolves(deps)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -615,10 +613,6 @@ describe('Launchpad: Setup Project', () => {
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fakeInstalledDeps()
|
||||
})
|
||||
|
||||
const hasStorybookPermutations = [false, true]
|
||||
|
||||
FRONTEND_FRAMEWORKS.forEach((framework) => {
|
||||
|
||||
@@ -19,12 +19,10 @@ function verifyConfigFile (configFile: `cypress.config.${'js' | 'ts'}`) {
|
||||
}
|
||||
|
||||
function fakeInstalledDeps () {
|
||||
cy.withCtx(async (ctx) => {
|
||||
cy.withCtx(async (ctx, o) => {
|
||||
const deps = (await ctx.wizard.packagesToInstall() ?? []).map((x) => x.package)
|
||||
|
||||
ctx.update((coreData) => {
|
||||
coreData.wizard.__fakeInstalledPackagesForTesting = deps
|
||||
})
|
||||
o.sinon.stub(ctx.wizard, 'installedPackages').resolves(deps)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user