The @WalmartLabs Blog

Read about how we’re innovating the way our customers shop.

  1. Unit Testing a Client-server AMD Code Base

    Posted on by Marissa Coren

    Written by Jason Strimpel, Staff Software Engineer, @WalmartLabs

    I’m a developer for a branch of @WalmartLabs in Carlsbad, Calif. (San Diego area), and one of the pain points we share with the community is unit testing AMD code bases. That’s why our team developed grunt-castle, a unit-testing Grunt plugin for AMD client, server, and client-server code bases. The plugin eases the pain of unit testing AMD code bases by reducing specification boilerplate, auto-resolving of paths, and auto-wiring and configuring other open source libraries.

    Today, I’m excited to announce the open sourcing of grunt-castle. We created it because we needed a way to efficiently unit test a new client-server JavaScript web framework (stay tuned for more on that) and internal Walmart Global eCommerce applications that run on the framework. We’re opening it up to the community to make their lives easier and get some feedback on how to make it better.

    What it does

    If you have unit tested an AMD code base before, you know first-hand the challenges it presents. For those who have not, I highly suggest reading Effective Unit Testing with AMD by Mike Pennisi.

    In addition to solving the issues Mike outlines grunt-castle wires together several open source projects required for automating the testing of client-server AMD code bases. If you are starting from scratch figuring out how to put these pieces together, configure them, and wrap them up with a convenient API can be challenging. When we set out to write grunt-castle there were four main requirements that we used as guidelines. Remember it does the following for both environments!

    • Environment Agnostic: We wanted to be able to write a specification once and have it run on both the client and server. Grunt-castle abstracts the environment differences, creates HTML specifications based on JavaScript specifications, spins up PhantomJS (for client tests), and kicks off Mocha.
    • Mocking: Another major pain point we had was mocking dependencies. We wanted the ability to easily mock a dependency anywhere in the dependency tree by simply providing a module id. Grunt-castle does this via a lightweight wrapper that proxies to Squire.js. Additionally, we wanted to be able to mock global objects and have these global objects cleaned up between each test and specification to prevent problems with specifications corrupting global objects and breaking tests in subsequent specifications. Grunt-castle does this by automatically creating a fresh copy of global objects that have been mocked between tests.
    • Path Resolution and Automation: Path issues can be quite challenging when it comes to unit testing AMD code. We wanted these issues automatically resolved, which is exactly what grunt-castle does. It uses the Grunt task configuration to resolve application and mock paths. It then uses these paths to configure RequireJS and load mocks, so that all you have to do is provide a module id. We also did not want to have load supporting libraries such as Chai or Sinon-Chai for each specification, so grunt-castle does this and makes them automatically available in specifications. We did not want to have to create HTML wrappers and worry about configuring paths correctly for the client either, so grunt-castle automatically generates HTML versions of all your specifications.
    • Code Coverage: Our last requirement was generating code coverage reports. We needed the ability to easily instrument code and generate LCOV reports that could be consumed by an internal reporting tool. We also wanted to generate HTML coverage reports that we could view locally to find coverage gaps. Grunt-castle does this by using the Mocha json-cov reporter and converting the results to LCOV. For the local reports it uses the Mocha coverage reporting templates.

     Getting Started

    Getting started with grunt-castle is a breeze. If you are not familiar with Grunt then I advise reading the Getting Started guide first. For those of you who are familiar with Grunt already I created an example project that will have you unit testing AMD code with grunt-castle in three easy steps.

    Things to Come

    Grunt-castle was built to abstract and encapsulate processes that we found necessary for unit testing a client-server web framework. Because of this the plugin’s scope became too large. In the future we would like to limit the plugin’s scope to running unit test and generating output via Mocha reporters. For instance, the instrumentation of code should not be the responsibility of grunt-castle, so this will likely be removed.

    Help Wanted

    This was the first Grunt plugin anyone of the team has authored and our previous experience with Grunt is limited, we’re always looking for open source contributors who are Grunt plugin experts from the community to help improve grunt-castle.

  2. Transforming Online Grocery Shopping with Yumprint

    Posted on by Ben Galbraith

    Did you know Walmart is the largest grocer here in the United States? It’s true; our best-selling item in the U.S. is bananas, and more than 140 million Americans visit us each week to stock up their pantry and pick up some other items along the way.

    We’ve been giving a lot of thought to how we can use technology to improve the grocery shopping experience for our customers. Of course, we’re already big and early adopters of technology, from our vaunted supply chain that helps drive our low prices to our web and mobile experiences that assist shoppers in planning their trips and making the most of their visits. But despite our accomplishments, our vision for the future is much bigger than what we’ve done so far.

    Along these lines, we’ve recently launched a small Walmart To Go grocery delivery pilot in the San Francisco/San Jose and Denver areas for shoppers to explore how our technology can help our customers save time as well as money, either by having their grocery orders delivered to their homes or ready for quick pick-up at participating stores for free.

    I’m pleased to announce another step we’re making in our journey to renovate the shopping experience: @WalmartLabs is acquiring Yumprint, an exciting start-up in the recipes and meal planning space. Yumprint founders Chris Crittenden and Wes Dyer had a vision for how technology can improve the way all of us discover and prepare our meals. Their website, iPhone app and browser extension are among the ideas they’ve brought to food lovers, helping them discover, search and save recipes from any website.

    Chris and Wes’s ideas and ambitions for transforming the grocery shopping experience match the global opportunity Walmart enjoys in this space, and their accomplishments with Yumprint just scratch the surface of what we’re going to do next together.

    Welcome to the ‘Labs, Wes and Chris. More than 140 million Americans can’t wait to see what you help us introduce next.

  3. 2000 Strong in Silicon Valley: Expanding to Sunnyvale

    Posted on by Marissa Coren

    Over the past year, the @WalmartLabs team has grown by leaps and bounds. We’ve hired new team members from some of the best tech brands in the Valley, and welcomed some of the Valley’s finest from Inkiru, OneOps and Tasty Labs. Our headquarters here in San Bruno house more than 1,000 associates. Together, we’re building a world-class Internet startup inside the world’s largest retailer.

    Today, I’m excited to share that we have officially opened our newest office in Sunnyvale. The office will be home to about 1,000 current and new associates in our growing technology team, most of whom will be in engineering and product development.

    One of the major projects this team is developing is our global platform, one unified platform designed to drive continuous growth and innovation for the eCommerce sites we operate for Walmart around the world. It’s already rolling out to and in the U.S. and to ASDA, our brand in the UK.

    Why Sunnyvale? San Francisco and the Peninsula tend to offer design, app and UI talent, and though there’s plenty of tech talent there, the South Bay has a higher concentration of engineers and technologists. We’re expanding to South Bay to geographically target this different skill set. Currently there are nearly 500 people in the Sunnyvale office, and we’re continuing to hire.

    Images of new the office can be found here.

    We’ve designed the Sunnyvale office with the sleek and collaborative “labs” feel in mind, an environment you’ll also find in our San Bruno offices. Dedicated work spaces and an open layout enable collaboration and innovation among our small agile teams.

    Our Sunnyvale office is the newest addition to our network of technology hubs around the world that include teams in Bangalore, Portland, San Diego and San Bruno. You’ll find talented technologists throughout this network working on exciting projects that will launch at a global scale only Walmart could enable. We hope you’ll join us on that journey.