mocha

NoMethodError: undefined method `mock' for minitest and mocha

自作多情 提交于 2019-12-25 05:18:44
问题 I'm developing a gem for Rails 3 and came across an error in my test suit when running it under Ruby 1.8.7 at travis-ci.org: /home/travis/.rvm/gems/ruby-1.8.7-p370/gems/minitest-3.5.0/lib/minitest/unit.rb:874:in `_run_suite': undefined method `run' for #<TestActivist:0xb6936dd4> (NoMethodError) 69 from /home/travis/.rvm/gems/ruby-1.8.7-p370/gems/minitest-3.5.0/lib/minitest/unit.rb:866:in `map' 70 from /home/travis/.rvm/gems/ruby-1.8.7-p370/gems/minitest-3.5.0/lib/minitest/unit.rb:866:in `_run

Promises in Mocha Unit Tests

£可爱£侵袭症+ 提交于 2019-12-25 04:45:47
问题 This question is related to Using Promises to test Meteor - Mocha Like Louis suggested, I have replicated the same issue in a smaller program, so that you can reproduce this. And in this one too Mocha doesn't care about the assert statement. The catch block of the promises gets this error. /server/main.js import { Meteor } from 'meteor/meteor'; export const myCollection = new Mongo.Collection('mycollection'); export const addObject = function (id) { myCollection.insert({ name: 'test ' + id })

How to test a custom module running node-fluent-ffmpeg (an async module)?

泄露秘密 提交于 2019-12-25 04:24:09
问题 How do I test a custom module which is simply running a node-fluent-ffmpeg command with Mocha&Chai? // segment_splicer.js var config = require('./../config'); var utilities = require('./../utilities'); var ffmpeg = require('fluent-ffmpeg'); module.exports = { splice: function(raw_ad_time, crop) { if (!raw_ad_time || !crop) throw new Error("!!!!!!!!!! Missing argument"); console.log("@@@@@ LAST SEGMENT IS BEING SPLITTED."); var segment_time = utilities.ten_seconds(raw_ad_time); var last

Why do I get error “Cannot overwrite model once compiled” in Mongoose when I run my test a second time?

你说的曾经没有我的故事 提交于 2019-12-25 02:57:25
问题 I have read related post: Cannot overwrite model once compiled Mongoose Problem is neither of these solution's helped me with my problem. I get the error in the title and I have following setup: Folder Structure: My models look like this: forums.js const mongoose = require("mongoose"); const Schema = mongoose.Schema; const topicGroupSchema = require("./topicGroups"); const forumSchema = new Schema({ title: String, topicGroups: [topicGroupSchema] }) const Forum = mongoose.model("forums",

Removing Executed SQL queries from the report output of Mocha test

好久不见. 提交于 2019-12-25 02:21:16
问题 Here is the reporter output: Mitchs-MacBook-Pro:tshirtShop Bugzy$ mocha --exit test/models/product-db.js sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:242:13 Product to DB Executing (default): INSERT INTO `product` (`product_id`,`name`,`description`,`price`,`discounted_price`,`image`,`image_2`,

Dockerfile - Unexpected token error in mocha

旧时模样 提交于 2019-12-25 01:52:32
问题 Below is the dockerfile which is stored as image tag somehub/someapp-specs : FROM ubuntu:trusty MAINTAINER Developer team <developerteam@abc.com> # Prevent dpkg source ENV TERM=xterm-256color # Set mirrors to ca RUN sed -i "s/http:\/\/archive./http:\/\/ca.archive./g" /etc/apt/sources.list # Install node.js RUN apt-get update && \ apt-get install curl -y && \ curl -sL http://deb.nodesource.com/setup_4.x | sudo -E bash - && \ apt-get install -y nodejs COPY . /app WORKDIR /app # Install

Hash-based navigation with puppeteer

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 23:55:42
问题 I am trying to navigate to the url which contains # in the url which is returning Error: Navigation Timeout Exceeded: 30000ms exceeded it('should go to new link', async function(){ await page.goto('https://example.com/#/abc', {waitUntil: 'networkidle2'}) await page.waitForNavigation() await page.waitFor(15000); }) Original code expects a path to a tag having value as #/abc await page.waitForSelector('a tag selector') await page.click('a tag selector') await page.waitForNavigation() await page

Test using Nock in a scheduleJob

我是研究僧i 提交于 2019-12-24 22:46:03
问题 I'm getting a problem with test the http request in a scheduleJob node. Well, I've changed the crontime to run every second as suggested here for easier testing. The problem is, I don't think the Nock that I created to test the http request works fine. Because when I do the console.log('res : ', res); it either returns undefined or does not print anything as shown here : enter image description here. Does anyone have any idea how to solve this? Index.js schedule = require('node-schedule'),

Mocha test. Import class from not exported namespace

依然范特西╮ 提交于 2019-12-24 20:59:51
问题 I need to write unit test for my Typescript app. I use Mocha test framework . I have got internal module(A) in my web app and class B there. namespace A { export class B { constructor() { } } } I need to write some unit test for class B. /// <reference path="path/A.ts" /> import { expect } from 'chai'; describe('B test', function () { describe('#constructor()', () => { it('Should create B with default data', () => { let b = new A.B(); expect(b.age).to.equal(90); }); }); }); I'm starting my

sinon spy on function not working

家住魔仙堡 提交于 2019-12-24 20:56:12
问题 I'm trying to write a standalone test for this simple middleware function function onlyInternal (req, res, next) { if (!ReqHelpers.isInternal(req)) { return res.status(HttpStatus.FORBIDDEN).send() } next() } // Expose the middleware functions module.exports = { onlyInternal } This does not work describe('success', () => { let req = { get: () => {return 'x-ciitizen-token'} } let res = { status: () => { return { send: () => {} } } } function next() {} let spy before(() => { spy = sinon.spy(next