Disney's Splash Mountain needs a rebrand, but what should it look like?

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/tH8FvggW1Ms/disney-splash-mountain-rebrand

Pressure has been mounting on Disney to rebrand Splash Mountain, one of its most well-known rides. Built in 1986, the ride is based on the 1946 film, Song of the South, which has not been released on home video in the US (and does not appear on Disney Plus) due to its glorification of slave culture and inclusion of racist tropes.

One detailed rendering shared on Twitter replaces the current ride's theme with the 2009 film The Princess and the Frog – a film praised for its celebration of black culture and the first to feature a black Disney princess. Many petitions have been launched calling for the rebrand of Splash Mountain, and over 21,000 people added their support to using The Princess and the Frog as a suitable replacement. 

If you haven't yet seen The Princess and the Frog, here's how to try Disney Plus for free.

Created by a self-named "Disney Park Aficionado" and podcast host, Frederick Chambers, the concept art tracks the journey through the rebranded Splash Mountain. Instead of the backdrop of the Reconstruction Era, the setting would be New Orleans in the 1920s Jazz Age. The Princess and the Frog's plot is centred around a river adventure, and so Chambers' design builds on the existing setup and space of Splash Mountain, negating the need for expensive remodelling – just "retheming". 

Detailed written description of the scenes accompany the rendering, from the queuing space, through to the launching area and the ride itself. Brer Rabbit and Brer Fox (the current Splash Mountain residents) are replaced by the cast of The Princess and the Frog, with Chambers' description setting out how that would work.

Princess and the Frog

The Princess and the Frog features the first black Disney Princess

"There is a huge need for diversity in the parks and this could help fill that need," the petition states. "Princess and the Frog is a beloved princess movie but has very little representation in the parks."

However, some commenters disagree, suggesting that The Princess and the Frog may not be the ideal theme for a thrill ride. Though the film does deserve more representation in the park, they say, its target demographic of 3-5 year olds would be excluded from riding due to height restrictions. The films Moana and Emperor's New Groove have also been suggested.

Splash Mountain

The current Splash Mountain theme

Disney has yet to comment on the mounting pressure and increasing chatter surrounding Splash Mountain, but the company has been known to rethink rides for cultural progression before. The Pirates of the Caribbean ride was redesigned to remove images of pirates auctioning off women for marriage, and a female pirate was also added to the scene.

In the midst of a wave of global protests in support of Black Lives Matter, creatives are standing together against racism. With the world re examining cultural symbols, this concept art is an example of how creatives can use their talents to enact change. Watch this space to see how Disney reacts.

Read more:

Banksy reveals brilliant plan for Bristol’s toppled Colston StatuePowerful New Yorker cover pays tribute to black lives lostTheme park design: the art of attractions

Motion Design for Rio Tigre “Olympiades”

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/XI6Yr7CE1jE/motion-design-rio-tigre-olympiades

Motion Design for Rio Tigre “Olympiades”
Motion Design for Rio Tigre “Olympiades”

abduzeedo06.23.20

Olympiades is Rio Tigre’s first music video, created by Raphaël Pazoumian, also singer/songwriter for the band. The Music Video, created in 3D with Cinema 4D was shaped around a song composed in between Paris and New York. Inspired by Greek Mythology, the video illustrates the singer’s journey, reinventing the band and his life 3500 miles from home.

The black & white virtual world breaks into pieces that will never touch the ground. The heavy feeling of having to start from scratch when everything you created seems to fall in front of your eyes, your own foundations getting weaker by the seconds are transcribed into this ancient world that breaks to be rebuilt someplace else, like an eternal loop of new beginnings. 

I will make this happen
Broken glass and freedom
I will lift my heart off the ground
Heavy rocks fall without a sound

Motion Design

Video

Stills

 


Basics to Designing Great Visual Content

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/CbsEe9uFktI/basics-to-designing-great-visual-content

They say a picture says a thousand words and that is absolutely true. Visual content generates a more profound effect that written word because it immerses the audience and makes the concept more relatable. How can you create visual content the right way to get maximum engagement? Leave some white space When an infographic or […]

The post Basics to Designing Great Visual Content appeared first on designrfix.com.

1 Hidden Microsoft Edge Features (and How to Use Them)

Original Source: https://www.hongkiat.com/blog/less-known-microsoft-features-and-how-to-use-them/

Best yet less-known features of Microsoft Edge and detail on how to use them effectively.

The post 1 Hidden Microsoft Edge Features (and How to Use Them) appeared first on Hongkiat.

Visit hongkiat.com for full content.

Apple AirPods sale: Amazing deal cuts AirPods Pro price to all-time low

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/yO2olRrrxT0/apple-airpods-pro-june-sale

It's rare to come across decent discounts on Apple products, which is why we were super-excited today to see these top Apple AirPods deals. In the US, right now you can save $30 off Apple AirPods Pro over at Verizon, and if you're in the UK, Amazon has also shaved £20 off the popular Apple headphones. 

These great deals take the Apple AirPods Pro price tag to an all-time low, so you'll need to be quick if you're interested. We've also found a great saving on the equally brilliant 2nd Gen Apple AirPods too, with a whopping £40 off at Amazon – taking the price down to just £159.  

The Apple AirPods Pro are the most recent, high-end of all the Apple AirPods, with an in-ear design that comfortably fits all, cancels noise and produces quality sound on the go. They come complete with a solid 4.5 hours listening time, with a quick 20 minute-charge giving you three hours playback. And with the AirPods Pro's sweat/ water resistance, these are great earbuds to use when you're down the gym, off for a run, or just for when you want to hear your favourite music when you're out and about.

Browse AirPods at Apple.com
The best Apple AirPods Pro and AirPods deals in the US
The best Apple AirPods Pro and AirPods deals in the UK

Not in the UK or the US? No worries. Our clever price comparison tool collects the best deals from around the world…

Related articles:

The best running headphones in 2020AirPods deals: today's BEST offersApple 'foldable' iPhone design sparks controversy

The best left-handed mouse you can buy in 2020

Original Source: http://feedproxy.google.com/~r/CreativeBloq/~3/SMXb6mg2nSU/best-left-handed-mouse

Looking for the best left-handed mouse can be difficult, as even in 2020, many mouse makers seem to neglect southpaws and churn out loads of right-handed mice, and hardly any for lefties.

This can be incredibly frustrating, as the humble mouse is one of the most important peripherals we use when interacting with our computers. For creatives, it's especially important to find a mouse that's comfortable to use, and for left-handed people, that can sometimes be a struggle.

This is where our guide to the best left-handed mice can help. We've collected the best mice for left-handed users, and listed them right here, so you can easily find the best one for your needs. 

Not all of these mice are designed just for lefties. Many of them are ambidextrous in design, so they can be comfortably used in any hand, and you'll still be able to reach every button. You'll notice that some mice on this page come with plenty of additional buttons. These can be configured to help speed up your workflow, and help you be even more productive. Of course, we also have left-handed mice that favour simplicity, and so still with that tried-and-tested two-button design. 

For more ambidextrous options, take a look at our main buying guide to the best mouse in 2020.

Left-handed mouse: the best options available now

Logitech G903 Left

The Logitech G903 is a wireless gaming mouse that does it all. Thanks to 11 programmable buttons and up to 12,000 DPI of accuracy, this left-handed mouse offers more than most could even use. The mechanical button tensioning (which gives you physical feedback through the button clicks) lets you personalise it exactly. Even more useful are the five profiles you can switch between – adjust settings like sensitivity and button uses to enable you to hop between designing, browsing, and gaming uses. Wireless charging using the PowerPlay mat is another great feature that makes that 32-hour battery life even less of a worry. You can leave the lighting on, lowering battery to 24-hours of use, without worry.

SteelSeries Sensei Ten

If you're after a left-handed gaming mouse, then your options are limited, but the good news is that many mouse makers are now embracing ambidextrous designs, which means their mice are comfortable to use for both left- and right-handed people. SteelSeries is one of those manufacturers, and the Sensei Ten combines a left-hand-friendly design with a brilliant sensor that makes it fast and accurate to use. There's loads of customisation options, and it comes with a Tilt Tracking feature, which keeps tracking your movements even when you’re lifting your mouse and putting it back down at tilted angles.

Microsoft Bluetooth Mobile Mouse 3600

The Microsoft Bluetooth Mobile Mouse 3600 is the best left-handed mouse for people on a budget. It's compact and affordable, but crucially, it's well built as well. It's ideal for people who travel a lot and want a dependable wireless mouse that they can easily carry around.

Its ambidextrous design means it's a great choice for left-handed users as well. Microsoft has a formidable reputation when it comes to peripherals, and the Microsoft Bluetooth Mobile Mouse 3600 is a great example of this.

Mad Catz Rat 1

The Mad Catz Rat 1 is a wired mouse that's impressive to look at but somehow remains low in price. The quirky aesthetic is functional too, as the design means the mouse can be adjusted to fit any hand for perfect ergonomic comfort. There are only three buttons, but that keeps this mouse light for travel (it can even be split to make it more compact). With multiple colour options and a very low price, this is a tough mouse to beat.  

SteelSeries Sensei 310 Left

The SteelSeries Sensei 310 is a mouse built for gamers, meaning it’s crammed full of useful tech that designers and general users alike can benefit from. A whopping 12,000 DPI capability makes this super-sensitive (if you have it set to that high level). An ARM 32-bit processor – once a dream even for smartphones – helps compute all this data so you end up with the smoothest end result, which is what it’s all about really, isn’t it?

Evoluent VerticalMouse 4

The Evoluent VerticalMouse 4 has gone through many generations since it first appeared in 2002, and it's still going strong. The ergonomic design keeps your wrist from twisting thereby creating maximum comfort and promising long-term wrist health. The optical sensor and pointer are adjustable and buttons are available for fingers and thumbs (there are six in total). This mouse isn't cheap, but as a designer it's worth shelling out a bit more if it means keeping your wrist and hands happy.

Read more:

Switch from Mac to Windows: A 3D artist's guideThe best free fonts for designersThe best computer for graphic design

A look at the making of Google Pixel 4

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/yHCjmj0Enjw/look-making-google-pixel-4

A look at the making of Google Pixel 4
A look at the making of Google Pixel 4

AoiroStudio06.22.20

Arthur Kenzo is an industrial designer working in the Google Industrial Design Team. He shared a look of the making of the Google Pixel 4. I do own the Pixel 4 and it’s quite fascinating to see some of the behind-the-scenes of what went through the process and designing Google’s flagship phone. There is a line from Arthur’s story that I really like and as I quote: ‘Pixel 4 was designed to be soft in the hand and approachable, human.’ I do agree that when holding the Pixel 4 feels just right in your hand, the back glass is not retaining any fingertip smudges which makes the phone really defined in terms of everyday experience. Whatever you like its design or not, I think it’s always rewarding to get a glimpse of its process.

Links

http://www.arthurkenzo.com/
https://www.behance.net/arthurkenzo

Pixel 4 was designed to be soft in the hand and approachable, human. The form has been carefully sculpted out of aluminum and curved Gorilla Glass 5. Pixel 4 design is confidently different, approachable and simple. The sophisticated yet fresh approach to materials, colors and finishes is uniquely Google.

Credits

Designed by Google Industrial Design Team
Image courtesy by Google


Why Are All Sites Optimizing For Smartphones?

Original Source: http://feedproxy.google.com/~r/Designrfix/~3/1MdfNVEnVI4/why-are-all-sites-optimizing-for-smartphones

Sites were developed for desktop devices at first but as the worldwide smartphone usage rate increased so did the site developers look for other ways to fit the desktop sensation into the much smaller screen. Mobile optimized sites offer a better experience via mobile devices than those that are not. There are millions of optimized […]

The post Why Are All Sites Optimizing For Smartphones? appeared first on designrfix.com.

Fun Animated Brand Film for Supernova Design Studio

Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/xVdA24Sz4YM/fun-animated-brand-film-supernova-design-studio

Fun Animated Brand Film for Supernova Design Studio
Fun Animated Brand Film for Supernova Design Studio

abduzeedo06.18.20

Supernova is a Boutique Design Studio that helps innovative brands and businesses tell their unique stories in playful and creative ways. Founded by sisters Asavari and Shaivalini Kumar, Supernova employs a multidisciplinary approach to branding that draws upon their collective expertise in communication design and animation direction (…and all things cat.). They also have a shiny new brand design with a colorful video to showcase their new identity. 

Branding and Motion Design

Creating magic through collaboration. 

Supernova we believe that building a memorable brand requires cultivating a meaningful connection with its audience. Through intelligent strategy, beautiful design and memorable storytelling, we help wonderful products and services cut through the noise so they can change the world.

Goodbye stuffy, formal meetings and flowery pitches! At Supernova we want to skip the small talk and really get to know your hopes and dreams. Think of us as an extension of your team. We cultivate close relationships to collectively define a scope of work and collaboratively solve problems to create bespoke design solutions tailored to your business goals.


Mirage JS Deep Dive: Using Mirage JS And Cypress For UI Testing (Part 4)

Original Source: https://www.smashingmagazine.com/2020/06/mirage-javascript-cypress-ui-testing/

Mirage JS Deep Dive: Using Mirage JS And Cypress For UI Testing (Part 4)

Mirage JS Deep Dive: Using Mirage JS And Cypress For UI Testing (Part 4)

Kelvin Omereshone

2020-06-17T10:30:00+00:00
2020-06-17T21:48:15+00:00

One of my favorite quotes about software testing is from the Flutter documentation. It says:

“How can you ensure that your app continues to work as you add more features or change existing functionality? By writing tests.”

On that note, this last part of the Mirage JS Deep Dive series will focus on using Mirage to test your JavaScript front-end application.

Note: This article assumes a Cypress environment. Cypress is a testing framework for UI testing. You can, however, transfer the knowledge here to whatever UI testing environment or framework you use.

Read Previous Parts Of The Series:

Part 1: Understanding Mirage JS Models And Associations
Part 2: Understanding Factories, Fixtures And Serializers
Part 3: Understanding Timing, Response And Passthrough

UI Tests Primer

UI or User Interface test is a form of acceptance testing done to verify the user flows of your front-end application. The emphasis of these kinds of software tests is on the end-user that is the actual person who will be interacting with your web application on a variety of devices ranging from desktops, laptops to mobile devices. These users would be interfacing or interacting with your application using input devices such as a keyboard, mouse, or touch screens. UI tests, therefore, are written to mimic the user interaction with your application as close as possible.

Let’s take an e-commerce website for example. A typical UI test scenario would be:

The user can view the list of products when visiting the homepage.

Other UI test scenarios might be:

The user can see the name of a product on the product’s detail page.
The user can click on the “add to cart” button.
The user can checkout.

You get the idea, right?

In making UI Tests, you will mostly be relying on your back-end states, i.e. did it return the products or an error? The role Mirage plays in this is to make those server states available for you to tweak as you need. So instead of making an actual request to your production server in your UI tests, you make the request to Mirage mock server.

For the remaining part of this article, we will be performing UI tests on a fictitious e-commerce web application UI. So let’s get started.

Our First UI Test

As earlier stated, this article assumes a Cypress environment. Cypress makes testing UI on the web fast and easy. You could simulate clicks and navigation and you can programmatically visit routes in your application. See the docs for more on Cypress.

So, assuming Cypress and Mirage are available to us, let’s start off by defining a proxy function for your API request. We can do so in the support/index.js file of our Cypress setup. Just paste the following code in:

// cypress/support/index.js
Cypress.on(“window:before:load”, (win) => {
win.handleFromCypress = function (request) {
return fetch(request.url, {
method: request.method,
headers: request.requestHeaders,
body: request.requestBody,
}).then((res) => {
let content =
res.headers.map[“content-type”] === “application/json”
? res.json()
: res.text()
return new Promise((resolve) => {
content.then((body) => resolve([res.status, res.headers, body]))
})
})
}
})

Then, in your app bootstrapping file (main.js for Vue, index.js for React), we’ll use Mirage to proxy your app’s API requests to the handleFromCypress function only when Cypress is running. Here is the code for that:

import { Server, Response } from “miragejs”

if (window.Cypress) {
new Server({
environment: “test”,
routes() {
let methods = [“get”, “put”, “patch”, “post”, “delete”]
methods.forEach((method) => {
this[method](“/*”, async (schema, request) => {
let [status, headers, body] = await window.handleFromCypress(request)
return new Response(status, headers, body)
})
})
},
})
}

With that setup, anytime Cypress is running, your app knows to use Mirage as the mock server for all API requests.

Let’s continue writing some UI tests. We’ll begin by testing our homepage to see if it has 5 products displayed. To do this in Cypress, we need to create a homepage.test.js file in the tests folder in the root of your project directory. Next, we’ll tell Cypress to do the following:

Visit the homepage i.e / route
Then assert if it has li elements with the class of product and also checks if they are 5 in numbers.

Here is the code:

// homepage.test.js
it(‘shows the products’, () => {
cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

You might have guessed that this test would fail because we don’t have a production server returning 5 products to our front-end application. So what do we do? We mock out the server in Mirage! If we bring in Mirage, it can intercept all network calls in our tests. Let’s do this below and start the Mirage server before each test in the beforeEach function and also shut it down in the afterEach function. The beforeEach and afterEach functions are both provided by Cypress and they were made available so you could run code before and after each test run in your test suite — hence the name. So let’s see the code for this:

// homepage.test.js
import { Server } from “miragejs”

let server

beforeEach(() => {
server = new Server()
})

afterEach(() => {
server.shutdown()
})

it(“shows the products”, function () {
cy.visit(“/”)

cy.get(“li.product”).should(“have.length”, 5)
})

Okay, we are getting somewhere; we have imported the Server from Mirage and we are starting it and shutting it down in beforeEach and afterEach functions respectively. Let’s go about mocking our product resource.

// homepage.test.js
import { Server, Model } from ‘miragejs’;

let server;

beforeEach(() => {
server = new Server({
models: {
product: Model,
},

routes() {
this.namespace = ‘api’;

this.get(‘products’, ({ products }, request) => {
return products.all();
});
},
});
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

Note: You can always take a peek at the previous parts of this series if you don’t understand the Mirage bits of the above code snippet.

Part 1: Understanding Mirage JS Models And Associations
Part 2: Understanding Factories, Fixtures And Serializers
Part 3: Understanding Timing, Response And Passthrough

Okay, we have started fleshing out our Server instance by creating the product model and also by creating the route handler for the /api/products route. However, if we run our tests, it will fail because we don’t have any products in the Mirage database yet.

Let’s populate the Mirage database with some products. In order to do this, we could have used the create() method on our server instance, but creating 5 products by hand seems pretty tedious. There should be a better way.

Ah yes, there is. Let’s utilize factories (as explained in the second part of this series). We’ll need to create our product factory like so:

// homepage.test.js
import { Server, Model, Factory } from ‘miragejs’;

let server;

beforeEach(() => {
server = new Server({
models: {
product: Model,
},
factories: {
product: Factory.extend({
name(i) {
return `Product ${i}`
}
})
},

routes() {
this.namespace = ‘api’;

this.get(‘products’, ({ products }, request) => {
return products.all();
});
},
});
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

Then, finally, we’ll use createList() to quickly create the 5 products that our test needs to pass.

Let’s do this:

// homepage.test.js
import { Server, Model, Factory } from ‘miragejs’;

let server;

beforeEach(() => {
server = new Server({
models: {
product: Model,
},
factories: {
product: Factory.extend({
name(i) {
return `Product ${i}`
}
})
},

routes() {
this.namespace = ‘api’;

this.get(‘products’, ({ products }, request) => {
return products.all();
});
},
});
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
server.createList(“product”, 5)
cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

So when we run our test, it passes!

Note: After each test, Mirage’s server is shutdown and reset, so none of this state will leak across tests.

Avoiding Multiple Mirage Server

If you have been following along this series, you’d notice when we were using Mirage in development to intercept our network requests; we had a server.js file in the root of our app where we set up Mirage. In the spirit of DRY (Don’t Repeat Yourself), I think it would be good to utilize that server instance instead of having two separate instances of Mirage for both development and testing. To do this (in case you don’t have a server.js file already), just create one in your project src directory.

Note: Your structure will differ if you are using a JavaScript framework but the general idea is to setup up the server.js file in the src root of your project.

So with this new structure, we’ll export a function in server.js that is responsible for creating our Mirage server instance. Let’s do that:

// src/server.js

export function makeServer() { /* Mirage code goes here */}

Let’s complete the implementation of the makeServer function by removing the Mirage JS server we created in homepage.test.js and adding it to the makeServer function body:

import { Server, Model, Factory } from ‘miragejs’;

export function makeServer() {
let server = new Server({
models: {
product: Model,
},
factories: {
product: Factory.extend({
name(i) {
return `Product ${i}`;
},
}),
},
routes() {
this.namespace = ‘api’;

this.get(‘/products’, ({ products }) => {
return products.all();
});
},
seeds(server) {
server.createList(‘product’, 5);
},
});
return server;
}

Now all you have to do is import makeServer in your test. Using a single Mirage Server instance is cleaner; this way you don’t have to maintain two server instances for both development and test environments.

After importing the makeServer function, our test should now look like this:

import { makeServer } from ‘/path/to/server’;

let server;

beforeEach(() => {
server = makeServer();
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
server.createList(‘product’, 5);

cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

So we now have a central Mirage server that serves us in both development and testing. You can also use the makeServer function to start Mirage in development (see first part of this series).

Your Mirage code should not find it’s way into production. Therefore, depending on your build setup, you would need to only start Mirage during development mode.

Note: Read my article on how to set up API Mocking with Mirage and Vue.js to see how I did that in Vue so you could replicate in whatever front-end framework you use.

Testing Environment

Mirage has two environments: development (default) and test. In development mode, the Mirage server will have a default response time of 400ms(which you can customize. See the third article of this series for that), logs all server responses to the console, and loads the development seeds.

However, in the test environment, we have:

0 delays to keep our tests fast
Mirage suppresses all logs so as not to pollute your CI logs
Mirage will also ignore the seeds() function so that your seed data can be used solely for development but won’t leak into your tests. This helps keep your tests deterministic.

Let’s update our makeServer so we can have the benefit of the test environment. To do that, we’ll make it accept an object with the environment option(we will default it to development and override it in our test). Our server.js should now look like this:

// src/server.js
import { Server, Model, Factory } from ‘miragejs’;

export function makeServer({ environment = ‘development’ } = {}) {
let server = new Server({
environment,

models: {
product: Model,
},
factories: {
product: Factory.extend({
name(i) {
return `Product ${i}`;
},
}),
},

routes() {
this.namespace = ‘api’;

this.get(‘/products’, ({ products }) => {
return products.all();
});
},
seeds(server) {
server.createList(‘product’, 5);
},
});
return server;
}

Also note that we are passing the environment option to the Mirage server instance using the ES6 property shorthand. Now with this in place, let’s update our test to override the environment value to test. Our test now looks like this:

import { makeServer } from ‘/path/to/server’;

let server;

beforeEach(() => {
server = makeServer({ environment: ‘test’ });
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
server.createList(‘product’, 5);

cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

AAA Testing

Mirage encourages a standard for testing called the triple-A or AAA testing approach. This stands for Arrange, Act and Assert. You could see this structure in our above test already:

it(“shows all the products”, function () {
// ARRANGE
server.createList(“product”, 5)

// ACT
cy.visit(“/”)

// ASSERT
cy.get(“li.product”).should(“have.length”, 5)
})

You might need to break this pattern but 9 times out of 10 it should work just fine for your tests.

Let’s Test Errors

So far, we’ve tested our homepage to see if it has 5 products, however, what if the server is down or something went wrong with fetching the products? We don’t need to wait for the server to be down to work on how our UI would look like in such a case. We can simply simulate that scenario with Mirage.

Let’s return a 500 (Server error) when the user is on the homepage. As we have seen in a previous article, to customize Mirage responses we make use of the Response class. Let’s import it and write our test.

homepage.test.js
import { Response } from “miragejs”

it(‘shows an error when fetching products fails’, function() {
server.get(‘/products’, () => {
return new Response(
500,
{},
{ error: “Can’t fetch products at this time” }
);
});

cy.visit(‘/’);

cy.get(‘div.error’).should(‘contain’, “Can’t fetch products at this time”);
});

What a world of flexibility! We just override the response Mirage would return in order to test how our UI would display if it failed fetching products. Our overall homepage.test.js file would now look like this:

// homepage.test.js
import { Response } from ‘miragejs’;
import { makeServer } from ‘path/to/server’;

let server;

beforeEach(() => {
server = makeServer({ environment: ‘test’ });
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
server.createList(‘product’, 5);

cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

it(‘shows an error when fetching products fails’, function() {
server.get(‘/products’, () => {
return new Response(
500,
{},
{ error: “Can’t fetch products at this time” }
);
});

cy.visit(‘/’);

cy.get(‘div.error’).should(‘contain’, “Can’t fetch products at this time”);
});

Note the modification we did to the /api/products handler only lives in our test. That means it works as we previously define when you are in development mode.

So when we run our tests, both should pass.

Note: I believe its worthy of noting that the elements we are querying for in Cypress should exist in your front-end UI. Cypress doesn’t create HTML elements for you.

Testing The Product Detail Page

Finally, let’s test the UI of the product detail page. So this is what we are testing for:

User can see the product name on the product detail page

Let’s get to it. First, we create a new test to test this user flow.

Here is the test:

it(“shows the product’s name on the detail route”, function() {
let product = this.server.create(‘product’, {
name: ‘Korg Piano’,
});

cy.visit(`/${product.id}`);

cy.get(‘h1’).should(‘contain’, ‘Korg Piano’);
});

Your homepage.test.js should finally look like this.

// homepage.test.js
import { Response } from ‘miragejs’;
import { makeServer } from ‘path/to/server;

let server;

beforeEach(() => {
server = makeServer({ environment: ‘test’ });
});

afterEach(() => {
server.shutdown();
});

it(‘shows the products’, function() {
console.log(server);
server.createList(‘product’, 5);

cy.visit(‘/’);

cy.get(‘li.product’).should(‘have.length’, 5);
});

it(‘shows an error when fetching products fails’, function() {
server.get(‘/products’, () => {
return new Response(
500,
{},
{ error: “Can’t fetch products at this time” }
);
});

cy.visit(‘/’);

cy.get(‘div.error’).should(‘contain’, “Can’t fetch products at this time”);
});

it(“shows the product’s name on the detail route”, function() {
let product = server.create(‘product’, {
name: ‘Korg Piano’,
});

cy.visit(`/${product.id}`);

cy.get(‘h1’).should(‘contain’, ‘Korg Piano’);
});

When you run your tests, all three should pass.

Wrapping Up

It’s been fun showing you the inners of Mirage JS in this series. I hope you have been better equipped to start having a better front-end development experience by using Mirage to mock out your back-end server. I also hope you’ll use the knowledge from this article to write more acceptance/UI/end-to-end tests for your front-end applications.

Part 1: Understanding Mirage JS Models And Associations
Part 2: Understanding Factories, Fixtures And Serializers
Part 3: Understanding Timing, Response And Passthrough
Part 4: Using Mirage JS And Cypress For UI Testing

Smashing Editorial
(ra, il)