Skip to content
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

fix(react): prevent generating empty props since setting strict in tsconfig is not compatible with it #26428

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/next/src/generators/page/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('component', () => {
const content = tree
.read('my-app/pages/posts/[dynamic]/index.tsx')
.toString();
expect(content).toMatch(/DynamicProps/);
});
});

Expand Down Expand Up @@ -97,7 +96,6 @@ describe('component', () => {
const content = tree
.read(`${appRouterProjectName}/app/posts/[dynamic]/page.tsx`)
.toString();
expect(content).toMatch(/DynamicProps/);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,12 @@ describe(AnotherCmp2.name, () => {

exports[`componentTestGenerator multiple components per file should handle no props 1`] = `
"import * as React from 'react'
import SomeLib, { SomeLibProps, AnotherCmp } from './some-lib'
import SomeLib, { AnotherCmp } from './some-lib'


describe(SomeLib.name, () => {
let props: SomeLibProps;

beforeEach(() => {
props = {
}
})

it('renders', () => {
cy.mount(<SomeLib {...props}/>)
cy.mount(<SomeLib />)
})
})

Expand All @@ -91,19 +84,12 @@ describe(AnotherCmp.name, () => {

exports[`componentTestGenerator multiple components per file should handle props 1`] = `
"import * as React from 'react'
import SomeLib, { SomeLibProps, AnotherCmpProps, AnotherCmp } from './some-lib'
import SomeLib, { AnotherCmpProps, AnotherCmp } from './some-lib'


describe(SomeLib.name, () => {
let props: SomeLibProps;

beforeEach(() => {
props = {
}
})

it('renders', () => {
cy.mount(<SomeLib {...props}/>)
cy.mount(<SomeLib />)
})
})

Expand Down Expand Up @@ -179,19 +165,12 @@ describe(AnotherCmp.name, () => {

exports[`componentTestGenerator single component per file should handle no props 1`] = `
"import * as React from 'react'
import SomeLib, { SomeLibProps } from './some-lib'
import SomeLib from './some-lib'


describe(SomeLib.name, () => {
let props: SomeLibProps;

beforeEach(() => {
props = {
}
})

it('renders', () => {
cy.mount(<SomeLib {...props}/>)
cy.mount(<SomeLib />)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ import { Route, Link } from 'react-router-dom';
var extras = '';
} %>

/* eslint-disable-next-line */
export interface <%= className %>Props {
}

<% if (styledModule && styledModule !== 'styled-jsx') { %>
const Styled<%= className %> = styled.div`
color: pink;
`;
<% }%>
<% if(!isNextPage) { %>
<% if (classComponent) { %>
export class <%= className %> extends Component<<%= className %>Props> {
export class <%= className %> extends Component<{}> {
override render() {
return (
<<%= wrapper %><%- extras %>>
Expand All @@ -51,7 +47,7 @@ const Styled<%= className %> = styled.div`
}
}
<% } else { %>
export function <%= className %>(props: <%= className %>Props) {
export function <%= className %>() {
return (
<<%= wrapper %><%- extras %>>
<% if (styledModule === 'styled-jsx') { %><style jsx>{`div { color: pink; }`}</style><% } %>
Expand All @@ -69,7 +65,7 @@ const Styled<%= className %> = styled.div`

export default <%= className %>;
<% } else { %>
export default function <%= className %>(props: <%= className %>Props) {
export default function <%= className %>() {
return (
<<%= wrapper %><%- extras %>>
<% if (styledModule === 'styled-jsx') { %><style jsx>{`div { color: pink; }`}</style><% } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,23 @@ describe(AnotherCmp.name, () => {

exports[`React:CypressComponentTestConfiguration should generate tests for existing tsx components 1`] = `
"import * as React from 'react';
import SomeLib, { SomeLibProps } from './some-lib';
import SomeLib from './some-lib';

describe(SomeLib.name, () => {
let props: SomeLibProps;

beforeEach(() => {
props = {};
});

it('renders', () => {
cy.mount(<SomeLib {...props} />);
cy.mount(<SomeLib />);
});
});
"
`;

exports[`React:CypressComponentTestConfiguration should generate tests for existing tsx components 2`] = `
"import * as React from 'react';
import AnotherCmp, { AnotherCmpProps } from './another-cmp';
import AnotherCmp from './another-cmp';

describe(AnotherCmp.name, () => {
let props: AnotherCmpProps;

beforeEach(() => {
props = {};
});

it('renders', () => {
cy.mount(<AnotherCmp {...props} />);
cy.mount(<AnotherCmp />);
});
});
"
Expand Down