-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: validate specPattern root level #19980
Changes from 5 commits
2123078
67dc001
308eb3d
1b984f3
26241c9
6c7694a
b6da23f
b53e599
21194b0
5b64d92
ced4624
fd579a1
69abb25
2db5c66
0b312ea
642b2e5
5373d0f
3b10efb
2fcfc78
2b1fd40
e4db6ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { expect } from 'chai' | ||
import { matchedSpecs, transformSpec, SpecWithRelativeRoot } from '../../../src/sources' | ||
import { matchedSpecs, transformSpec, SpecWithRelativeRoot, BrowserApiShape } from '../../../src/sources' | ||
import path from 'path' | ||
import { DataContext } from '../../../src' | ||
import { graphqlSchema } from '@packages/graphql/src/schema' | ||
import { AppApiShape, AuthApiShape, ElectronApiShape, LocalSettingsApiShape, ProjectApiShape } from '../../../src/actions' | ||
import { ErrorApiShape } from '../../../src/DataContext' | ||
import { InjectedConfigApi } from '../../../src/data' | ||
|
||
describe('matchedSpecs', () => { | ||
context('got a single spec pattern from --spec via cli', () => { | ||
|
@@ -114,3 +120,60 @@ describe('transformSpec', () => { | |
expect(result).to.eql(actual) | ||
}) | ||
}) | ||
|
||
describe('findSpecs', () => { | ||
const temporary = 'tmp' | ||
|
||
const fixture = [ | ||
'component/App.spec.ts', | ||
'component/App.cy.ts', | ||
'component/App.cy.js', | ||
'e2e/onboarding.spec.ts', | ||
'e2e/onboarding.cy.ts', | ||
'e2e/onboarding.cy.js', | ||
] | ||
|
||
let ctx: DataContext | ||
|
||
beforeEach(async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I wonder if we want a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah! we may want to move to a util, that can be really useful so we can create more unit tests for different dataSources and dataActions |
||
ctx = new DataContext({ | ||
schema: graphqlSchema, | ||
mode: 'run', | ||
modeOptions: {}, | ||
appApi: {} as AppApiShape, | ||
localSettingsApi: {} as LocalSettingsApiShape, | ||
authApi: {} as AuthApiShape, | ||
errorApi: {} as ErrorApiShape, | ||
configApi: { | ||
getServerPluginHandlers: () => [], | ||
} as InjectedConfigApi, | ||
projectApi: {} as ProjectApiShape, | ||
electronApi: {} as ElectronApiShape, | ||
browserApi: {} as BrowserApiShape, | ||
}) | ||
|
||
await Promise.all(fixture.map((element) => ctx.fs.outputFile(path.join(temporary, element), ''))) | ||
}) | ||
|
||
afterEach(async () => { | ||
await ctx.fs.remove(temporary) | ||
}) | ||
|
||
it('find all the *.cy.{ts,js} excluding the e2e', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, we definitely needed these tests. |
||
const specs = await ctx.project.findSpecs(temporary, 'component', ['**/*.cy.{ts,js}'], ['e2e/*.{spec,cy}.{ts,js}'], []) | ||
|
||
expect(specs).to.have.length(2) | ||
}) | ||
|
||
it('find all the *.{cy,spec}.{ts,js} excluding the e2e', async () => { | ||
const specs = await ctx.project.findSpecs(temporary, 'component', ['**/*.{cy,spec}.{ts,js}'], ['e2e/*.{spec,cy}.{ts,js}'], []) | ||
|
||
expect(specs).to.have.length(3) | ||
}) | ||
|
||
it('find all the e2e specs', async () => { | ||
const specs = await ctx.project.findSpecs(temporary, 'e2e', ['e2e/*.{cy,spec}.{ts,js}'], [], []) | ||
|
||
expect(specs).to.have.length(3) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
ignoreSpecPattern: 'src/**/*.cy.js', | ||
e2e: {}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
specPattern: 'src/**/*.cy.js', | ||
e2e: {}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
supportFile: 'cypress/support/e2e.js', | ||
e2e: {}, | ||
} |
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.
I wonder if this should be the default for CT. @cowboy maybe?
I also think
baseUrl
should be disallowed top level, it's E2E only. We should defs go over the config changes w/ a fine toothed comb to make sure everything is 💯, but this PR is definitely a good start.