Skip to content

Commit

Permalink
fix assertion in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Mar 18, 2023
1 parent 2ec4d1f commit 0cd7c39
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ describe('Preact Component Tests', () => {
it('should test component with WebdriverIO', async () => {
<%- renderCommand %>
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ describe('React Component Tests', () => {
it('should test component with WebdriverIO', async () => {
<%- renderCommand %>
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ describe('Preact Component Tests', () => {
it('should test component with WebdriverIO', async () => {
<%- renderCommand %>
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ describe('Svelte Component Testing', () => {
it('should test component with WebdriverIO', async () => {
<%- renderCommand %>
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ describe('Vue Component Testing', () => {
it('should test component with WebdriverIO', async () => {
<%- renderCommand %>
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 2')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
9 changes: 5 additions & 4 deletions packages/wdio-cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,14 @@ export function getPathForFileGeneration(answers: Questionnair, projectRootDir:
export async function getDefaultFiles(answers: Questionnair, pattern: string) {
const projectProps = await getProjectProps()
const rootdir = getProjectRoot(answers, projectProps)
const isJSX = TSX_BASED_FRAMEWORKS.includes(answers.preset || '')
const presetPackage = convertPackageHashToObject(answers.preset || '')
const isJSX = TSX_BASED_FRAMEWORKS.includes(presetPackage.short || '')
const val = pattern.endsWith('.feature')
? path.join(rootdir, pattern)
: answers?.isUsingCompiler?.toString().includes('TypeScript')
? `${path.join(rootdir, pattern)}.ts`
: `${path.join(rootdir, pattern)}.js`
return val + (isJSX ? 'x' : '')
? `${path.join(rootdir, pattern)}.ts${isJSX ? 'x' : ''}`
: `${path.join(rootdir, pattern)}.js${isJSX ? 'x' : ''}`
return val
}

/**
Expand Down
50 changes: 30 additions & 20 deletions packages/wdio-cli/tests/__snapshots__/onboarding.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ describe('Svelte Component Testing', () => {
it('should test component with WebdriverIO', async () => {
render(ExampleComponent)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -66,13 +67,14 @@ describe('Svelte Component Testing', () => {
it('should test component with WebdriverIO', async () => {
new ExampleComponent({ target: container, props: {} })
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -110,13 +112,14 @@ describe('Vue Component Testing', () => {
it('should test component with WebdriverIO', async () => {
render(ExampleComponent, { props: { msg: 'WebdriverIO Component Testing' } })
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 2')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -148,13 +151,14 @@ describe('Vue Component Testing', () => {
it('should test component with WebdriverIO', async () => {
createApp(ExampleComponent, { msg: 'WebdriverIO Component Testing' }).mount(container)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 2')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -214,13 +218,14 @@ describe('Preact Component Tests', () => {
it('should test component with WebdriverIO', async () => {
render(<ExampleComponent />)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -255,13 +260,14 @@ describe('Preact Component Tests', () => {
const root = createRoot(container)
root.render(<ExampleComponent />)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -295,13 +301,14 @@ describe('React Component Tests', () => {
it('should test component with WebdriverIO', async () => {
render(<ExampleComponent />)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -333,13 +340,14 @@ describe('React Component Tests', () => {
const root = createRoot(container)
root.render(<ExampleComponent />)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -374,13 +382,14 @@ describe('Preact Component Tests', () => {
it('should test component with WebdriverIO', async () => {
render(() => <ExampleComponent />)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down Expand Up @@ -410,13 +419,14 @@ describe('Preact Component Tests', () => {
it('should test component with WebdriverIO', async () => {
render(<ExampleComponent />, container)
const component = await $('button=count is 0')
const component = await $('button*=count is')
await expect(component).toBePresent()
await expect(component).toHaveText('count is 0')
await component.click()
await component.click()
await expect($('button=count is 2')).toBePresent()
await expect(component).toHaveText('count is 2')
})
})
"
Expand Down
2 changes: 1 addition & 1 deletion packages/wdio-cli/tests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ test('getDefaultFiles', async () => {
.toBe(path.join('/bar', 'foo', 'bar.js'))
expect(await getDefaultFiles({ projectRootCorrect: false, projectRoot: '/bar', isUsingCompiler: COMPILER_OPTION_ANSWERS[1] } as any, files))
.toBe(path.join('/bar', 'foo', 'bar.ts'))
expect(await getDefaultFiles({ projectRootCorrect: false, projectRoot: '/bar', isUsingCompiler: COMPILER_OPTION_ANSWERS[1], preset: 'react' } as any, files))
expect(await getDefaultFiles({ projectRootCorrect: false, projectRoot: '/bar', isUsingCompiler: COMPILER_OPTION_ANSWERS[1], preset: 'vite-plugin-solid$--$solid' } as any, files))
.toBe(path.join('/bar', 'foo', 'bar.tsx'))
expect(await getDefaultFiles({ projectRootCorrect: false, projectRoot: '/bar', isUsingCompiler: COMPILER_OPTION_ANSWERS[2] } as any, files))
.toBe(path.join('/bar', 'foo', 'bar.js'))
Expand Down

0 comments on commit 0cd7c39

Please sign in to comment.