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

Jest tests copied to output folder when using --generate-delta #744

Closed
1 task done
mmindenhall opened this issue Dec 22, 2023 · 5 comments · Fixed by #745
Closed
1 task done

Jest tests copied to output folder when using --generate-delta #744

mmindenhall opened this issue Dec 22, 2023 · 5 comments · Fixed by #745
Assignees
Labels
bug Something isn't working

Comments

@mmindenhall
Copy link
Contributor

mmindenhall commented Dec 22, 2023

Issue verification check:

  • is the current repository fully deployable at the commit SHA provided with the 'from' parameter of the command?

What is the problem?

My employer has been gradually building jest tests for LWCs.

When there are changes in the source of an LWC with jest tests, sgd --generate-delta copies the __tests__ folder (contains the jest test sources) to the output folder, despite the .forceignore passed to sgd specifying that this folder should be ignored.

What is the parameter and the value you used with it?

See reproduction steps below.

What is the expected result?

The expected result is that the output folder would not contain the __tests__ folder for any LWC with jest tests.

What is the actual result?

The output folder contains the __tests__ folder and its contents, which causes the subsequent sf force source deploy -p /tmp/output/folder command to fail due to the jest .js file(s) not being deployable.

Steps to reproduce

  1. Clone my sfdx-git-delta-reproduction-playground fork

  2. Check out the issue/744 branch

  3. Run this command:

    $ sf sgd source delta --from HEAD~1 --to HEAD --source sgd --output output --ignore .forceignore --generate-delta --json
    
  4. Verify that the __tests__ folder was copied into the tree in the output folder


Execution context


Operating System:
Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
yarn version:
1.22.19
node version:
v18.16.0
git version:
git version 2.43.0
sfdx version:
@salesforce/cli/2.21.8 darwin-arm64 node-v18.16.0
sgd plugin version:
sfdx-git-delta 5.31.1

More information (optional)


@mmindenhall mmindenhall added the bug Something isn't working label Dec 22, 2023
@scolladon
Copy link
Owner

Hi @mmindenhall!

Thanks for raising this very well detailed issue and thanks for contributing in making this project better!

What is the content of the .forceignore file used to ignore __tests__ folders please?

Do you reproduce it with any LWC component ? Or some of them have particularities?

@mmindenhall
Copy link
Contributor Author

Hi @scolladon!

Here's the .forceignore for the package where we encountered this problem.

# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#
package.xml
# LWC configuration files
**/jsconfig.json
**/.eslintrc.json
# LWC Jest
**/__tests__/**
# Profiles
**/force-app/main/default/profiles/**
# Fields
**/Contact/fields/CleanStatus.field-meta.xml
# Custom Index
**/force-app/main/default/customindex/**

**/AppSwitcher.appMenu-meta.xml
**/LightningService_UtilityBar.flexipage-meta.xml
**/profiles/**

I'm pretty sure the behavior will happen with any LWC component when using --generate-delta. The one I used to reproduce the problem in my fork of sfdx-git-delta-reproduction-playground was a simple Hello World LWC, using the .forceignore already in sfdx-git-delta-reproduction-playground.

@mmindenhall
Copy link
Contributor Author

BTW I took a quick peek at the source code, and I think this is what's happening. The --ignore file is being used to filter files to process out of the git output, but no filtering is being applied in the copy operation to the output folder. I think the --ignore file patterns need to be applied in both places.

@scolladon
Copy link
Owner

Thank you for spiking a bit @mmindenhall.
I see now what is happening here, I'll propose a fix next week hopefully.

Stay tuned!

Copy link

github-actions bot commented Jan 9, 2024

Shipped in release v5.32.0.
You can install the new version using the version number or the latest-rc channel

$ sfdx plugins:install sfdx-git-delta@latest-rc
$ sfdx plugins:install sfdx-git-delta@v5.32.0

Happy incremental deployment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants