teleren/devto huggingface dataset:
Javascript Testing With Mocha
Tags: javascript, programming, softwaredevelopment, mocha
Published: 2019-07-29 20:39:12

---
title: Javascript Testing With Mocha
published: true
tags: javascript,programming,software-development,mocha
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/1024/1*EgEulBNpsN6Nw_bwy33NKA.jpeg)

### Javascript Testing

One of my favorite parts about going to a coding bootcamp was all the automated tests. It was incredibly helpful to see whether my code contained errors, and to get hints about what might be causing those errors.

Now that I’ve graduated it’s up to me to write those tests for my own projects!

I had written some Ruby tests using Capybara, so now I wanted to try my hand at writing Javascript tests.

### Mocha

In honor of “May the 4th Be With You” my alternative title for this post is “May the Mocha Be With You.” I found that Mocha was easy to get up and running and a pleasure to use.

Mocha is a Javascript testing framework. It works for testing JS in the browser, as well as JS that is executed in a node JS environment.

### My First Mocha Test

I decided to write a Mocha test that would be executed in the node JS environment.

Here is the code:

```
// Require the built in 'assertion' library
 var assert = require('assert');

describe('Compare', function() {
 describe('Star Wars Quotes', function() {
 it('should test whether two data types are equivalent ', function() {
 assert.equal(true, typeof "May the Fourth Be With You" === typeof "Help me Obi Wan Kenobi, you're my only hope")
 })
 })
 })
```

This test passes, because both operands are strings, so function will return the expected output of true.

### Lessons Learned

The Getting Started guide on [mochajs.org](https://mochajs.org/#getting-started) has very basic instructions on how to get your first Mocha test running.

However, I kept getting an error message about my package.json file whenever I tried to run “npm test.” The error message claimed “no such file or directory” existed. Eventually I ran the command “npm init” from within the project directory. That created a package.json file within my project directory and that fixed the problem.

### Resources

There are a lot of great resources out there to learn Mocha if you are interested. Of course, there is the official documentation at [mochajs.org](https://mochajs.org/#getting-started).

There is also a more in-depth tutorial on medium by [codeburst](https://codeburst.io/how-to-test-javascript-with-mocha-the-basics-80132324752e)
Using Laravel Model Factories To Generate Dummy Data
Tags: laravelmodel, modelfactories, laravelseeds
Published: 2019-05-04 20:43:34

---
title: Using Laravel Model Factories To Generate Dummy Data
published: true
description: Laravel Model Factories allow you to generate fake data for your eloquent models. Model Factories are very useful for testing and seeding fake data to see if your application work as it suppose to be.
tags:  LARAVEL MODEL, MODEL FACTORIES, LARAVEL SEEDS
---

Laravel Model Factories allow you to generate fake data for your eloquent models. Model Factories are very useful for testing and seeding fake data to see if your application work as it suppose to be.

In this post, we will look at how we can create model factories and generate dummy data using the Faker Library which ships with Laravel.

Read the full article at [https://www.larashout.com/using-laravel-model-factories-to-generate-dummy-data](https://www.larashout.com/using-laravel-model-factories-to-generate-dummy-data)
How To Use Adapter Pattern in Laravel
Tags: designpatterns, adapterdesignpattern
Published: 2019-05-04 20:40:31

---
title: How To Use Adapter Pattern in Laravel
published: true
description: There are various ways to structure the code and project for your web application. But it is usually a good idea to follow common design patterns because it will make your code easier to manage and easier for others to understand.
tags: DESIGN PATTERNS, ADAPTER DESIGN PATTERN
---

In this post, we will look at how we can use the Adapter Pattern in Laravel. Throughout this post, we will look at the usage and benefits of this pattern using a real-world example.

One thing we can not neglect when creating web application is the Change, it can be in requirements or the third party APIs you are relying your code on. You might think your system is designed perfectly, there are always chances that you will get a new request for a change in your code which will ruin your whole application design.

The Adapter Pattern is a design pattern which deals with the change.

Read the full article at [https://www.larashout.com/how-to-use-adapter-pattern-in-laravel](https://www.larashout.com/how-to-use-adapter-pattern-in-laravel)
Was C# killed by JavaScript?
Tags: csharp, programming
Published: 2019-05-04 20:32:00

---
title: Was C# killed by JavaScript?
published: true
description: C#, programming
tags: csharp, programming
---
<img src="https://cdn.pixabay.com/photo/2018/04/20/21/10/code-3337044__340.jpg" alt="csharp">

No, C# is the 5th most popular programming language. They are also very different programming languages.  See TIOBE rating here: https://www.tiobe.com/tiobe-index/

C# is  widely used. It's used 

* to develop video games with Unity
* websites and back-end processes and with ASP.NET
* multitudinous desktop applications with Windows Form Applications 
* and now WPF applications
* universal Windows applications that can be deployed on PC’s.

read more: https://csharp1.com/
Intro to Alexa Skill Development
Tags: alexa, beginners, javascript, tutorial
Published: 2019-05-04 19:06:33

---
title: Intro to Alexa Skill Development
published: true
description: Get started with your first custom Alexa skill for free using the Alexa-Hosted option. No credit card necessary.
tags: Alexa, beginner, javascript, tutorial
---

If you ever wanted to build your first Alexa Skill, checkout my tutorial on the Amazon Developer Forum. It shows how you can get started for free. Happy skill development!

<center><h2>Click Below 👇</h2></center>

[![Intro to Alexa Skill Development tutorial](https://thepracticaldev.s3.amazonaws.com/i/9fs8uu8vcv10l2iyehl9.png)](https://forums.developer.amazon.com/content/kbentry/204223/build-your-first-alexa-skill-as-an-alexa-hosted-sk.html)

_If you'd like updates on more content like this, follow me on Twitter **[@itspanw](https://twitter.com/itspanw)**_
Dev Update Vlog 002
Tags: discuss, startup, webdev, showdev
Published: 2019-05-04 18:51:02

---
title: Dev Update Vlog 002
published: true
description: The second episode in my weekly series of dev update videos. This week I go over a couple small updates I made while I had family in town visiting.
tags: discuss,startup,webdev,showdev
---

I'm documenting my development progress on my two products: [RemoteAuth](https://remoteauth.com) and [Released](https://released.xyz). 

This week I had family engagements which took up the majority of my week, but I did manage to get a couple small features done!

Check out the video to see what my plans for next week are!

{% youtube LO8qJc9RAW4 %}
Tech writing goals for May 2019
Tags: writing, opensource, security
Published: 2019-05-04 18:27:30

---
title: Tech writing goals for May 2019
published: true
description: 
tags: writing, opensource, security
---

I always set monthly goals, but never thought about sharing them publicly until I was inspired by: 

{% link jsjoeio/2019-goals-april-update-45f3 %}

My technical writing goals for May are:

- Learn how to set up a custom CA cert using Kubernetes and CockroachDB
- Research UX microcopy principles and best practices
- Open source my writing process on YouTube

![Jon Snow](https://media.giphy.com/media/Lm63QU87HvgVEuTV63/giphy.gif)
Not Documented, Not Done
Tags: documentation
Published: 2019-05-04 17:37:57

---
title: Not Documented, Not Done
published: true
description: A tale of documentation from someone who hated documenting, but can't live without it.
tags: Documentation
---

This is my first post anywhere, so be gentle! :)
Also, this is my opinion based on my work experience and in the type of projects I have encountered. I would love to hear your opinions on the article in the comments!

I know what you're thinking. **Everyone hates documenting stuff.**

Take for example doing your taxes. I hated doing the taxes until they implemented a mechanism for me to click "Yes, I confirm" and be done with it. But we do taxes because **we have to**. Documenting is based on the same principle.

Nowadays I've turned a new leaf and I'm actually really fond of documenting. I try to document everything I can, with as much detail as necessary. I believe in teaching my junior team members the same thing. As soon as they enter my team they quickly realize if it's **Not Documented, It's Not Done.**

> Note: Documenting and Commenting are two separate things. Think of code like a problem: while commenting mitigates, documenting fixes.

When I started my first job, the moment we got an email saying that we won a new contract, was also the moment we started writing the code. **There is no worse practice than this in software development!**

> Software development is like building a house. First you study the best approach, you review it, then you get your hands dirty.

This has happened to me more times than I can remember. (Un)Fortunately I'm usually the firefighter who needs to put out some major fires in different types of projects. Maybe that's one of the reasons why I now like to document a lot.

Imagine you are put on a project already on course and you have 3 days to implement a feature without absolutely no context at all. What would you give to see a really good written manual about what the project does, and how does it do it.

> Everyone likes starting a project from scratch and just going heads on to the code. Nobody likes entering a mid-finishing project without knowing properly what happened.

Help your local firefighter colleagues and document people! Be it in .md, a word file, or even a Visio that explains the flow of the application you're developing!

I hoped you enjoyed the article!

* What are your feelings on documenting? Do you like it or do you hate it?
* How do you usually document?
* Are you normally the firefighter in you team? :)
What is GoLang?
Tags: go, programming
Published: 2019-05-04 17:34:00

---
title: What is GoLang?
published: true
description: golang
tags: golang, programming
---
Golang is a programming language created by Google. It uses concurrency as first class construct. On top of the golang is simple: Golang is so simple, you can learn it in a weekend! 

Why Learn golang?

* go is easy to learn
* golang has an easy to use interface
* great for web development, even front end (GopherJS)
* real language used to solve real problems.
* loads of work out there for Golang (EU & USA)
* lot of current top-notch applications are being written in Go


Tutorial:

* https://golangr.com
As an individual engineer, what do you look for in a manager?
Tags: discuss, career, management
Published: 2019-05-04 15:07:13

---
title: As an individual engineer, what do you look for in a manager?
published: true
description: If you could choose your engineering manager, what sort of person would you choose?
tags: discuss, career, management
---

You're an individual contributor, and you've just been informed that you'll have the opportunity to choose your next engineering manager.

What are the most important qualities you would look for?

What would be the biggest deal-breakers?

What sort of person would you ideally hope to find?
Free modern, project based HTML/CSS course for beginners
Tags: html, css, flexbox
Published: 2019-05-04 14:53:54

---
title: Free modern, project based HTML/CSS course for beginners
published: true
description: Learn how to move from design to implementation for a real world project
tags: html, css, flexbox
cover_image: https://thepracticaldev.s3.amazonaws.com/i/w4eo1a7elc1ke3bf3lho.png
---

When I started out as a developer, I learnt so many `HTML` tags, and as many `CSS` rules as I could learn, but every time I built a website, it somehow did not end up looking like a website. To learn, I used to download free  templates online, just to have a look at how they were built so I could learn. 

Why the hell are there so many nested `div`s ? How do these people even think about such structures? It always felt like building websites was a complicated science. Well if you are at that point in your career, this course is for you.

I created a [free, practical course](https://bahdcasts.com/courses/modern-responsive-web-design) to teach you how to implement this design [this mockup](https://www.figma.com/file/36lnVYiFkIERJJyhxGH6ka/HTML5-CSS3-FLEXBOX-RESPONSIVE-DESIGN-COURSE), covering so much about implementing practical designs in HTML & CSS, with a little touch of flexbox, just enough to get you going as a developer.

Here's a list of things we'll learn in this short course:

- How to get started setting up a new project
- Moving from any design tool to HTML/CSS
- How to build responsive layouts with flex box
- Designing common web components
- Design tips for more responsive web designs

And so much more.

Please share this course with someone who needs it 🔥. 

Don't forget checkout my other free courses on [my website](https://bahdcasts.com)
I'm from India. How do I collect payments for my application?
Tags: startup, indiehackers, help, payments
Published: 2019-05-04 14:38:37

Hi Fellow Hackers,

I'm Sunil from India. I'm planning to build an application where I would like to receive payments from different countries. I'm not looking for accepting payments through links/ko-fi/donate buttons etc. In my use case first I take card details from customers. If they fail to do some activity, then I'm gonna charge them using the card details collected earlier. What are the payment gateway integrations I can use?

I have created an account on Stripe. But currently Stripe is not supported in India. Only people from specific set of countries can activate their account and can start using Stripe APIs. So Stripe is not an option for me.

I was also looking at Razorpay, which is from India and is very similar to Stripe. But Razorpay currently doesn't support solo developers.

What are my other options to receive payments from customers through their card details?

PS: I'm trying to avoid using PayPal as much as possible. If I don't have any other option at all, then I'll think of using PayPal.

Any help/comments are appreciated.

![](https://media.giphy.com/media/8vRrxHIZlJT2xvo920/giphy.gif)
Replacing text using regex groups in VSCode
Tags: regex, vscode
Published: 2019-07-05 11:42:55

---
title: Replacing text using regex groups in VSCode
published: true
tags: regex,vscode
canonical_url: https://ofdigitalwater.postach.io/post/replacing-text-using-regex-groups-in-vscode
---

You can save much time by using regular expressions in the _Replace_ dialog of _Visual Studio Code_ editor. The captured groups can be recalled as `$1`, `$2` etc in the replacement field of the same dialog.
Foreword: Space-Ready Publishing with Gatsby and IPFS
Tags: ipfs, gatsby, dweb, webdev
Published: 2019-05-07 12:28:48

---
title: Foreword: Space-Ready Publishing with Gatsby and IPFS
published: true
tags: ipfs, gatsby, dweb, webdev
canonical_url: https://interplanetarygatsby.com/foreword
---

 **[Interplanetary Gatsby](https://interplanetarygatsby.com)** is a blog about making **space-grade websites**.

“Static” and “offline-first” don’t really do them justice.

**In space, there is no such thing as “online”** —this naïve illusion of near-simultaneity bore by the small window of low-latency communications that graced our species in the few decades that followed millenia of foot, horse, and sea, and preceded our belated (re)launch into the deeper waters of the cosmic ocean.

For light is slow, and so far as our minds have been able to see, there is no short-term escape to its grasp on the reach of our interstellar voice.

Asynchronicity is all that is or ever was or ever will be.

* * *

Mars is 3.2 light-minutes away at its closest and 22.2 light-minutes away at its farthest.

Imagine clicking a link to a news article and sitting there for a _minimum_ of **6 minutes** for it to load.

It doesn’t matter how hand-optimized the page is or how high your bandwidth. That’s the fixed cost that the very first bit will have to crawl through before it gets to you.

How do you design around this constraint?

You cache the hell out of everything. You prefetch. You reach out to people on your own planet before capitulating to the space link. You change the user experience to decouple fetching from reading, you queue and notify instead of blocking and spinning.

These are the things I want to explore with [Gatsby](https://gatsbyjs.org) and [IPFS](https://ipfs.io "InterPlanetary File System")—the InterPlanetary File System.

They are the perfect tools for this job, and I invite you to join me on this journey _into the vastness of the Merkleverse_.
Introducing a newly updated HTML reporter for Newman
Tags: newman, reports, api, testing
Published: 2019-05-04 12:49:47

---
title: Introducing a newly updated HTML reporter for Newman
published: true
description: A new version of the Newman HTML reporter with some added extras 😁
tags: Newman,reports,api,testing
---

I wanted to give something back to the Postman community and that something is a new, updated version of the HTML reporter. 

There is a lot of information that comes from Newman and this was missing from the standard reporter so I decided to create a reporter that not only exposes some of this data, it also gives you a few extra things too. ❤️

A picture paints a thousand words...here is a demo working copy of the final report. Feel free to have a look around.

https://s3.eu-west-2.amazonaws.com/newman-htmlextra-reports/All_Passed.html

The full reporter and the different available features, can be found in the link below. 

Please download the NPM package and check it with your own collections. 🚀

https://github.com/DannyDainton/newman-reporter-htmlextra

Enjoy.
The secret that the fonts industry doesn't want you to know
Tags: css, discuss
Published: 2019-05-04 11:34:58

---
title: The secret that the fonts industry doesn't want you to know
published: true
description: Finally the story of CSS's most unsung hero
cover_image: https://thepracticaldev.s3.amazonaws.com/i/b1piigcvdgarjkgrrzec.jpg
tags: 
  - css
  - discuss
---


One of my favorite tricks recently has become to use `currentColor` as a flavor to almost anything. Quite unknown for a long time, I'm pretty sure that [Lea Verou](http://lea.verou.me/) was the first person to ever use and expose it to the world.

While CSS variables are [fucking awesome](https://www.youtube.com/watch?v=UQRSaG1hQ20), it's 1. not always possible to use them yet (oh _sweet_ IE 11) and 2. not always necessary.

Let's go for an example. Remember how everybody loves icon fonts because they automatically get the color of the font? Turns out you can do the same thing with SVG with a greater control.

Well suppose your code looks like this:

```html
<nav class="menu">
    <a class="item">
        <svg><path d="..."/></svg>
        JavaScript
    </a>
    <a class="item">
        <svg><path d="..."/></svg>
        Python
    </a>
    <a class="item">
        <svg><path d="..."/></svg>
        Sass
    </a>
</nav>
```

You want the SVG icon in front of the text to change with the text's color. What do you do?

```html
<svg><path d="..."/></svg>
```

Becomes

```html
<svg><path fill="currentColor" d="..."/></svg>
```

And that's it, your SVG has the color of the text no matter what. Here's a live example, don't forget to hover the buttons!

{% jsfiddle https://jsfiddle.net/xowap/s8zxq5f1/27/ result %}

Have you noticed how the Python logo doesn't change color completely on hover? You don't have to put the `currentColor` to every path in the SVG. Much more freedom than with fonts!

It's a simple trick but I really used it a lot recently. What about you, what patterns can you think of with `currentColor`?
Docker Launched Next Generation Application Docker Enterprise 3.0
Tags: docker, docker30, enterprisedocker, dockerlaunched
Published: 2019-05-04 10:52:27

---
title: Docker Launched Next Generation Application Docker Enterprise 3.0
published: true
description: Docker, one of the eminent holder stage suppliers, has declared its most recent advancement, Docker Enterprise 3.0, as of late at a compartment client gathering. With this all-new holder stage, developers can immediately create applications and convey them to the clients.  
tags: docker, docker 3.0, enterprise docker, docker launched
---
<img src="https://thepracticaldev.s3.amazonaws.com/i/ync13qum2wpytrmx8f2x.png" alt="Docker enterprise 3.0">

Docker, one of the eminent holder stage suppliers, has declared its most recent advancement, Docker Enterprise 3.0, as of late at a compartment client gathering. With this all-new holder stage, developers can immediately create applications and convey them to the clients. Carefully changing the pattern of utilization advancement, Docker Enterprise 3.0 fills in as a start to finish answer for making application improvement and arrangement simpler than any time in recent memory.

Read the full article here: https://www.decipherzone.com/blog-detail/Docker-Launched-Docker-Enterprise-3-0
Pushing Left, Like a Boss — Part 5.1 — Input Validation, Output Encoding and Parameterized Queries
Tags: applicationsecurity, tutorial, beginners, security
Published: 2019-05-04 10:42:47

---
title: Pushing Left, Like a Boss — Part 5.1 — Input Validation, Output Encoding and Parameterized Queries
published: true
description: The 5th section of this series details various examples of secure coding.
series: Pushing Left Like a Boss
tags: applicationsecurity, tutorial, beginners, security
---
###This series, and my blog, have moved! [Check it out](https://wehackpurple.com/g8tg)!

After writing up my secure coding guideline and finding it was over 11 pages, my editor informed me that it was inappropriate to publish as a single blog post. With compromise in mind, and in the hopes that people continue reading my blog, I agreed to break up the guideline into several shorter posts. The first few posts will be in-depth details of several of the items for the guideline, then a final post which will be a short, concise guideline, with links to each of the previous posts for further explanation.

![Image Credit: WOCTechChat](https://thepracticaldev.s3.amazonaws.com/i/vm2g0h92ssoq7p112vtp.jpeg)


###[Read the rest on my NEW blog!](https://wehackpurple.com/mfo5)!