Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax-m1· MiniMaxHugging Face LMArena Human Preference 140K

How do i add Safari browser E2E tests in Cypress?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-pro-preview-05-06’s answer.
  1. User

    How do i add Safari browser E2E tests in Cypress?

  2. MiniMax Assistant

    To add Safari browser E2E tests in Cypress, follow these steps:


    1. Prerequisites

    • Cypress Version: Ensure you're using Cypress v9.3.0 or newer (Safari support was added experimentally in v9.3.0).
    • Safari Configuration:
      • Enable the Develop menu in Safari:
        Safari > Preferences > Advanced > Show Develop menu.
      • Enable Remote Automation:
        Develop > Allow Remote Automation.

    2. Configure Cypress for Safari

    Update your cypress.config.js to:

    • Enable experimental session support (required for Safari).
    • Explicitly add Safari to the browser list (if not auto-detected).
    const { defineConfig } = require("cypress");
    
    module.exports = defineConfig({
      e2e: {
        browsers: [
          // Other browsers (optional)
          'chrome',
          'edge',
          // Add Safari explicitly
          {
            name: 'safari',
            channel: 'stable',
            family: 'webkit',
            displayName: 'Safari',
            version: '16.5', // Match your installed version
            majorVersion: 16,
          }
        ],
      },
      experimentalSessionSupport: true, // Required for Safari
    });
    

    3. Run Tests on Safari

    Use one of these methods to execute tests:

    Option 1: CLI Command

    npx cypress run --browser safari
    

    Option 2: Cypress Test Runner

    1. Open the Cypress Test Runner:
      npx cypress open
    2. Select Safari from the browser dropdown.

    4. Handle Safari-Specific Behaviors

    Safari has stricter security policies. You may need to adjust tests for:

    • Cross-Origin Requests: Use cy.origin() to handle cross-origin interactions.
      cy.origin('https://example.com', () => {
        cy.get('.selector').click();
      });
      
    • Third-Party Cookies: Ensure Safari allows cookies for your domain.
    • Viewport/Resizing: Safari may block cy.viewport() changes; test responsive behavior conditionally.

    5. Verify Safari Detection

    Check if Cypress recognizes Safari:

    npx cypress info
    

    Look for safari in the list of detected browsers.


    Troubleshooting

    • Safari Not Listed?
      Ensure Safari is installed and the cypress.config.js is correctly configured.
    • Tests Fail with cy.origin Errors?
      Verify experimentalSessionSupport: true in your config.
    • CI/CD Issues?
      Ensure the CI environment has Safari installed and remote automation enabled.

    Example Test

    describe('Safari Test', () => {
      it('Visits example.com', () => {
        cy.visit('https://example.com');
        cy.get('h1').should('contain', 'Example');
      });
    });
    

    For more details, refer to the Cypress Safari Documentation.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.