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

in M1 Mac Approvals is Not Automatically Opening the Diff editor for received & approved Json Files #312

Open
saicharansigiri opened this issue Oct 4, 2022 · 9 comments

Comments

@saicharansigiri
Copy link

saicharansigiri commented Oct 4, 2022

in M1 Mac Approvals is Not Automatically Opening the Dif for received & approved Json Files when there is some Difference between both the Files(received&approved)

@saicharansigiri saicharansigiri changed the title in M1 Mac Approvals is Not Automatically Opening the Dif for received & approved Json Files in M1 Mac Approvals is Not Automatically Opening the Diff editor for received & approved Json Files Oct 4, 2022
@LarsEckart
Copy link
Contributor

Can you provide a bit more info on your dev environment. What IDE were you using when running tests. Which diff viewer application do you expect to open. Was it a plain ApprovalsTest, or using Options or @UseReporter annotation?

@bdhaak
Copy link

bdhaak commented Jan 24, 2023

I had the same problem. OSX Monterey, M1. I ended up making my own Reporter for the time being:

`
@test
public void testWithApprovalTests() {
...
Options options = new Options().withReporter(MyIntelliJMacSiliconReporter.INSTANCE);
Approvals.verify("abc", options);
}

public static class MyIntelliJMacSiliconReporter extends GenericDiffReporter {
private static final List TEXT = GenericDiffReporter.TEXT_FILE_EXTENSIONS;
public static final MyIntelliJMacSiliconReporter INSTANCE =
new MyIntelliJMacSiliconReporter();
public MyIntelliJMacSiliconReporter() {
super(new DiffInfo("/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea",
"diff %s %s", TEXT));
}
}`

@LarsEckart
Copy link
Contributor

LarsEckart commented Jan 25, 2023

thank you for the code snippet! we will look into this now.

Still a bit surprised that this is connected to M1 mac, as I am developing ApprovalTests since 2021 already with a M1 mac, but I notice that you used the path to Intellij Community Edition, that might be the case why we haven't noticed this ourselves yet, as I'm using the Ultimate edition. :)

@LarsEckart
Copy link
Contributor

We spent quite some time on it today, we didn't manage to fully fix it yet though and then time ran out, but we're on it.

If in the meantime you could provide us for example the path on your machine where it tried to find IntelliJ, and where your intellij installation actually is, that would be helpful so that we've some extra inputs for our test.

@LarsEckart
Copy link
Contributor

Just a note, we continued to work on this today but time is limited and we didn't progress very far. But we're on it :)

@ragunathjawahar
Copy link
Contributor

Also, @saicharansigiri is using Android Studio to write his approval tests.

@saicharansigiri
Copy link
Author

Apologies from my side, this got missed in Mails.
I was using Android Studio Electric Eel | 2022.1.1 , com.approvaltests:approvaltests:18.5.0 for writing unit test cases

@bdhaak
Copy link

bdhaak commented Apr 21, 2023

It seems the IntelliJPathResolver is not generating/detecting the correct path to the InteliJ executable. Maybe have a global config as fallback option for those that have a different install base. Maybe also generate a more meaningful exception in the logs ("Cannot find intellij install base folder, please specify with -DinteliJHomeFolder=/path/to/intellij"

@ayezutov
Copy link

Is there a fix planned for this?

I ended up creating three new resolvers:


public class InteliJMacCommunityReporter extends GenericDiffReporter {
    public static final InteliJMacCommunityReporter INSTANCE =
            new InteliJMacCommunityReporter();
    public InteliJMacCommunityReporter() {
        super(new DiffInfo("/Applications/IntelliJ IDEA CE.app/Contents/MacOS/idea",
                "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS));
    }
}

public class InteliJMacUltimateReporter extends GenericDiffReporter {
    public static final InteliJMacUltimateReporter INSTANCE =
            new InteliJMacUltimateReporter();

    public InteliJMacUltimateReporter() {
        super(new DiffInfo("/Applications/IntelliJ IDEA.app/Contents/MacOS/idea",
                "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS));
    }
}

public class InteliJMacReporter extends FirstWorkingReporter {
    public InteliJMacReporter() {
        super(InteliJMacCommunityReporter.INSTANCE, InteliJMacUltimateReporter.INSTANCE);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants