Sha256: c729745f13944803d2bca33506d39aecda143e53b25322d0ff0512262e978455

Contents?: true

Size: 1.56 KB

Versions: 36

Compression:

Stored size: 1.56 KB

Contents

# Testing

#### Table of contents

[Using test helpers inside your application](#using-test-helpers-inside-your-application)

[Testing an embedded app outside the Shopify admin](#testing-an-embedded-app-outside-the-shopify-admin)

## Using test helpers inside your application

A test helper that will allow you to test `ShopifyApp::WebhookVerification` in the controller from your app, to use this test, you need to `require` it directly inside your app `test/controllers/webhook_verification_test.rb`.

```ruby
    require 'test_helper'
    require 'action_controller'
    require 'action_controller/base'
    require 'shopify_app/test_helpers/webhook_verification_helper'
```

Or you can require in your `test/test_helper.rb`.

```ruby
  ENV['RAILS_ENV'] ||= 'test'
  require_relative '../config/environment'
  require 'rails/test_help'
  require 'byebug'
  require 'shopify_app/test_helpers/all'
```

With `lib/shopify_app/test_helpers/all'` more tests can be added and will only need to be required in once in your library.

## Testing an embedded app outside the Shopify admin

By default, loading your embedded app will redirect to the Shopify admin, with the app view loaded in an `iframe`. If you need to load your app outside of the Shopify admin (e.g., for performance testing), you can change `forceRedirect: true` to `false` in `ShopifyApp.init` block in the `embedded_app` view. To keep the redirect on in production but off in your `development` and `test` environments, you can use:

```javascript
forceRedirect: <%= Rails.env.development? || Rails.env.test? ? 'false' : 'true' %>
```

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
ruby_shopify_app-1.3.3 docs/shopify_app/testing.md
ruby_shopify_app-1.3.2 docs/shopify_app/testing.md
ruby_shopify_app-1.3.1 docs/shopify_app/testing.md
ruby_shopify_app-1.3.0 docs/shopify_app/testing.md
ruby_shopify_app-1.2.0 docs/shopify_app/testing.md
ruby_shopify_app-1.1.0 docs/shopify_app/testing.md
ruby_shopify_app-1.0.0 docs/shopify_app/testing.md
shopify_app-21.3.1 docs/shopify_app/testing.md
shopify_app-21.3.0 docs/shopify_app/testing.md
shopify_app-21.2.0 docs/shopify_app/testing.md
shopify_app-21.1.1 docs/shopify_app/testing.md
shopify_app-21.1.0 docs/shopify_app/testing.md
shopify_app-21.0.0 docs/shopify_app/testing.md
shopify_app-20.2.0 docs/shopify_app/testing.md
shopify_app-20.1.1 docs/shopify_app/testing.md
shopify_app-20.1.0 docs/shopify_app/testing.md
shopify_app-20.0.2 docs/shopify_app/testing.md
shopify_app-20.0.1 docs/shopify_app/testing.md
shopify_app-20.0.0 docs/shopify_app/testing.md
shopify_app-19.1.0 docs/shopify_app/testing.md