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

Default 'exclude' config for swc don't include all test file extensions #9442

Closed
jasongerbes opened this issue Mar 22, 2022 · 1 comment · Fixed by #9540
Closed

Default 'exclude' config for swc don't include all test file extensions #9442

jasongerbes opened this issue Mar 22, 2022 · 1 comment · Fixed by #9540

Comments

@jasongerbes
Copy link
Contributor

Current Behavior

The default options for the exclude option in .lib.swcrc don't match the following test file extensions:

  • .test.ts
  • .test.tsx
  • .spec.tsx

Here are the some of the default options for reference:

{
    "exclude": [
        "./src/**/.*.spec.ts$",
        "./**/.*.spec.ts$",
        "./src/**/jest-setup.ts$",
        "./**/jest-setup.ts$",
        "./**/.*.js$"
    ]
}

Furthermore, since swc exclude uses Regex, there's no need to have both ./src/**/... and ./**/... variations of each excluded file extension.

Expected Behavior

The default swc options should be improved to exclude the file extensions listed above. They can also be simplified to remove the ./src variants, for example:

{
    "exclude": [
        ".*.spec.tsx?$",
        ".*.test.tsx?$",
        "./src/jest-setup.ts$",
        "./**/jest-setup.ts$",
        ".*.js$"
    ]
}

(I left the jest-setup.ts values the same as these don't seem to be working)

Steps to Reproduce

  1. Create a new JS library with SWC: nx generate @nrwl/js:library --name=test-lib --compiler=swc
  2. Add a test file to the library with one of the extensions listed above: e.g. src/lib/tests/my-test.test.ts
  3. Build the library: nx build test-lib
  4. Check the build output, notice the my-test.test.ts hasn't been excluded.

Failure Logs

N/A

Environment

Node : 16.14.2
OS   : darwin x64
npm  : 8.5.0

nx : 13.9.4
@nrwl/angular : undefined
@nrwl/cypress : 13.9.4
@nrwl/detox : undefined
@nrwl/devkit : 13.9.4
@nrwl/eslint-plugin-nx : 13.9.4
@nrwl/express : undefined
@nrwl/jest : 13.9.4
@nrwl/js : 13.9.4
@nrwl/linter : 13.9.4
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : 13.1.6
@nrwl/nx-plugin : undefined
@nrwl/react : 13.9.4
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.9.4
@nrwl/web : 13.9.4
@nrwl/workspace : 13.9.4
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
barbados-clemens pushed a commit that referenced this issue Mar 28, 2022
include update to simplify existing patterns

ISSUES CLOSED: #9442
barbados-clemens pushed a commit that referenced this issue Mar 28, 2022
include update to simplify existing patterns

ISSUES CLOSED: #9442
barbados-clemens added a commit that referenced this issue Apr 11, 2022
)

include update to simplify existing patterns

ISSUES CLOSED: #9442

Co-authored-by: Caleb Ukle <caleb@Calebs-MBP-2.localdomain>
FrozenPandaz pushed a commit that referenced this issue Apr 13, 2022
)

include update to simplify existing patterns

ISSUES CLOSED: #9442

Co-authored-by: Caleb Ukle <caleb@Calebs-MBP-2.localdomain>
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants