question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: array.every is not a function

See original GitHub issue

When running npm t i get the “TypeError: array.every is not a function” error. My code is very similar to yours.

var expect = require('chai').expect;
var dogBreedNames = require('./index');

describe('Dog breeds?', function () {

    describe('all', function () {

        it('should be a array of strings', function () {
            expect(dogBreedNames.all).to.satisfy(isArrayOfStrings);
            function isArrayOfStrings(array) {
                return array.every(function(item){
                    return typeof item === 'string'
                });
            }
        });

    });

});

and the index.js is the following:

var uniqueRandomArray = require('unique-random-array');
var dogBreedNames = require('./dogs.json');

var getRandomItem = uniqueRandomArray(dogBreedNames);

module.exports = {
    all: dogBreedNames,
    random: uniqueRandomArray(dogBreedNames)
};

function random(number) {
  if (number === undefined) {
    return getRandomItem();
  } else {
    var randomItems = [];
    for (var i = 0; i < number; i++) {
      randomItems.push(getRandomItem());
    }
    return randomItems;
  }
}

Thanks, -Sohail

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mig-25commented, Aug 22, 2016

Solved it, there was the white space in travis.yml file for the script code, and I also needed to change the script attribute from -npm run test:single to

  • npm run test-single

21 aug. 2016 kl. 21:38 skrev Sohail Hasware sohail.hasware@gmail.com:

thanks, you were right. My json file for dogs was not in a array format. Thats what that happens if you stay up late 😃 I would like to take this opportunity to thank you. The course on egghead.io http://egghead.io/ is probably the best tutorial I have seen on front-end process.

Installing semantic-release globally didn’t put it local node_modules folder and update package.json file as devDependencie. I needed also to do a sudo npm install -D semantic-release

When I am at lesson 15 https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-automatically-releasing-with-travisci#/tab-transcript and do git push I got a error message for the travis build. I don’t if it has to do with the error pointing to Build failures due to new sudo-enabled Precise and Trusty images https://www.traviscistatus.com/incidents/11hp8bhkrkn7 or that my build#1 in travis is generating an error in the travis.yml file itself. This is how the error looks like:

<>ERROR: An error occured while trying to parse your .travis.yml file. <> <>Please make sure that the file is valid YAML. <> <>http://lint.travis-ci.org http://lint.travis-ci.org/ can check your .travis.yml. <> <>The log message was: Build config file had a parse error: did not find expected ‘-’ indicator while parsing a block collection at line 13 column 3. and this is how my travis.yml looks like:

sudo: false language: node_js cache: directories: - node_modules notifications: email: false node_js:

  • ‘4’ before_install:
  • npm i -g npm@^2.0.0 before_script:
  • npm prune script:
  • npm run test:single after_success:
  • npm run semantic-release branches: except:
- /^v\d+\.\d+\.\d+$/

Do you know what the issue could be about?

brgds Sohail once again, a really wonderful tutorial 😃

20 aug. 2016 kl. 07:00 skrev Kent C. Dodds <notifications@github.com mailto:notifications@github.com>:

Ah, my guess is that dogBreedNames.all is not an array. Try adding some console.logs in there to get an idea of what you’re actually calling every on.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kentcdodds/starwars-names/issues/21#issuecomment-241179899, or mute the thread https://github.com/notifications/unsubscribe-auth/AGyTLOQ5XzLSwsRuQqMzNkqZt5Z6UUcrks5qhon7gaJpZM4Jo-YK.

0reactions
mig-25commented, Aug 26, 2016

Thanks, I have been looking at that code 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve every is not a function in JavaScript
The “every is not a function” error occurs, when we call a every() method on a value which is not array. To fix...
Read more >
Why is .every() not a function?
No, it's just jQuery object. jQuery objects are very array-like, but they aren't arrays. Worse, they have some array-like methods (such as ...
Read more >
Solve - every is not a function in JavaScript
The “every is not a function” error occurs, when we call a every() method on a value which is not array. To fix...
Read more >
Array.prototype.every() - JavaScript - MDN Web Docs
The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value....
Read more >
TypeError: some is not a function in JavaScript [Solved]
The "TypeError: some is not a function" error occurs when the some() method is called on a value that is not an array....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found