-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sanitize internal vite plugins (#22055)
* fix: sanitize internal vite plugins
- Loading branch information
Showing
8 changed files
with
415 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
spec: 'test/**/*.spec.ts', | ||
timeout: 10000, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect } from 'chai' | ||
import { EventEmitter } from 'events' | ||
import * as vite from 'vite' | ||
import { scaffoldSystemTestProject } from './test-helpers/scaffoldProject' | ||
import { createViteDevServerConfig } from '../src/resolveConfig' | ||
import type { ViteDevServerConfig } from '../src/devServer' | ||
|
||
const getViteDevServerConfig = (projectRoot: string) => { | ||
return { | ||
specs: [], | ||
cypressConfig: { | ||
projectRoot, | ||
}, | ||
devServerEvents: new EventEmitter(), | ||
onConfigNotFound: () => {}, | ||
framework: 'react', | ||
viteConfig: {}, | ||
} as unknown as ViteDevServerConfig | ||
} | ||
|
||
describe('resolveConfig', function () { | ||
this.timeout(1000 * 60) | ||
|
||
context('inspect plugin', () => { | ||
it('should not include inspect plugin by default', async () => { | ||
const projectRoot = await scaffoldSystemTestProject('vite-inspect') | ||
const viteDevServerConfig = getViteDevServerConfig(projectRoot) | ||
|
||
const viteConfig = await createViteDevServerConfig(viteDevServerConfig, vite) | ||
|
||
expect(viteConfig.plugins).to.have.lengthOf(1) | ||
expect(viteConfig.plugins[0].name).to.equal('cypress:main') | ||
}) | ||
|
||
context('with CYPRESS_INTERNAL_VITE_INSPECT provided', () => { | ||
before(() => { | ||
process.env.CYPRESS_INTERNAL_VITE_INSPECT = 'true' | ||
}) | ||
|
||
after(() => { | ||
process.env.CYPRESS_INTERNAL_VITE_INSPECT = undefined | ||
}) | ||
|
||
it('should add inspect plugin', async () => { | ||
const projectRoot = await scaffoldSystemTestProject('vite-inspect') | ||
const viteDevServerConfig = getViteDevServerConfig(projectRoot) | ||
|
||
const viteConfig = await createViteDevServerConfig(viteDevServerConfig, vite) | ||
|
||
expect(viteConfig.plugins).to.have.lengthOf(2) | ||
expect(viteConfig.plugins[1].name).to.equal('cypress:inspect') | ||
}) | ||
|
||
it('should not add inspect plugin if not installed', async () => { | ||
const projectRoot = await scaffoldSystemTestProject('vite2.9.1-react') | ||
const viteDevServerConfig = getViteDevServerConfig(projectRoot) | ||
|
||
const viteConfig = await createViteDevServerConfig(viteDevServerConfig, vite) | ||
|
||
expect(viteConfig.plugins).to.have.lengthOf(1) | ||
expect(viteConfig.plugins[0].name).to.equal('cypress:main') | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Fixtures, { ProjectFixtureDir } from '@tooling/system-tests' | ||
import * as FixturesScaffold from '@tooling/system-tests/lib/dep-installer' | ||
|
||
export async function scaffoldSystemTestProject (project: ProjectFixtureDir) { | ||
Fixtures.removeProject(project) | ||
|
||
await Fixtures.scaffoldProject(project) | ||
|
||
await FixturesScaffold.scaffoldProjectNodeModules(project) | ||
|
||
return Fixtures.projectPath(project) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"devDependencies": { | ||
"react": "^17.0.0", | ||
"vite": "2.9.1", | ||
"vite-plugin-inspect": "0.5.0" | ||
}, | ||
"projectFixtureDirectory": "react" | ||
} |
Oops, something went wrong.
3b5a245
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
3b5a245
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: