npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

assertivity

v1.0.3

Published

Natural approach to JavaScript asserting and testing.

Downloads

13

Readme

assertivity

Assertivity es un framework de testing y expresiones booleana para JavaScript.

Los principales objetivos de este proyecto son:

  • Facilitar el uso y la lectura de expresiones booleanas para JavaScript.

  • Ofrecer una herramienta de testeo intuitiva y completa.

  • Facilitar la obtención de informes de los testeos legibles, flexibles, y completos.

Instalación

~$ npm install --save-dev assertivity

Uso

1. Importar la Assertivity API:
var {it, its, report} = require("assertivity").generate();
2. Usar la Assertivity API

API


Reference: {Assertivity}.it()

Type: {Function}

Returns: {Object:Assertive verbs}

Properties: {Object:Assertive verbs}

Usage:

  • Parameters: {Any:main}

  • Description: Establece la referencia principal para las aserciones venideras en el valor main pasado. También puede usarse como pivote para llamar a los verbos asertivos, sin llamarse como función.

  • Example:

it(800).is.number(); // true
it("Hello").is.string(); // true
it([]).is.boolean(); // false
it.is.array(); // true
it.is.not.empty(); // false
its("length").is(0); // true

Reference: {Assertivity}.its()

Type: {Function}

Returns: {Object:Assertive verbs}

Properties: {none}

Usage:

  • Parameters: [{String:selector}]+

  • Description: Establece los selectores de la referencia temporal para la aserción siguiente. Los selectores representan propiedades, y serán accedidas anidadamente, en orden, y desde el valor de la referencia principal.

  • Example:

it({a:{b:90,c:80}});
its("a","b").is(90); // true
its("a","c").is(80); // true

Reference: {Assertivity}.report

Type: {Object}

Returns: {{Assertivity}.report.into, {Assertivity}.report.as}

Properties: {none}

Usage: (as property)

  • Description: Esta propiedad se utiliza como pivote para acceder a los 2 métodos relacionados con el testing/reporting, en lugar del asserting. Los 2 métodos a los que se hace referencia son: into y as.

  • Example:

report.into("Main Test > Part 1", "Subpart 1 > Element 1").that(80).is.number();
report.into(undefined).as("Some label").that(80).is.number();
report.as("Some label").that(90).is.number();

Reference: {Assertivity}.report.into()

Type: {Function}

Returns: {as,that}

Parameters: {String:main}[, {String:subselector}]*

  • Description: Esta propiedad se utiliza como pivote para acceder a los 2 métodos relacionados con el testing/reporting, en lugar del asserting. Los 2 métodos a los que hago referencia son: into y as.

  • Example:

report.into("Main Test > Part 1", "Subpart 1 > Element 1").that(80).is.number();
report.into(" > Subpart 1 > Element 2").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 1.Element 2
report.into(" > Subpart 1 > Element 3").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 1.Element 3
report.into(" > Subpart 1 > Element 4").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 1.Element 4
report.into(" > Subpart 2 > Element 1").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 2.Element 1
report.into(" > Subpart 2 > Element 2").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 2.Element 2
report.into(" > Subpart 2 > Element 3").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 2.Element 3
report.into(" > Subpart 2 > Element 4").that(80).is.number(); // registered at: Main Test.Part 1.Subpart 2.Element 4
report.into(undefined).that(80).is.number(); // not registered

Reference: {Assertivity}.report.as()

Type: {Function}

Returns: {that}

Parameters: {String:label}

Usage 1:

  • Description: Esta propiedad se utiliza como pivote para acceder a los 2 métodos relacionados con el testing/reporting, en lugar del asserting. Los 2 métodos a los que hago referencia son: into y as.

  • Example:

it({a:{b:90,c:80}});
its("a","b").is(90); // true
its("a","c").is(80); // true

Reference: {Object:Assertive verbs}

Type: {Object}

Methods:

~.is()

~.is.true()

~.is.truthy()

~.is.false()

~.is.falsy()

~.is.equal.to()

~.is.similar.to()

~.is.like()

~.is.different.from()

~.is.defined()

~.is.undefined()

~.is.something()

~.is.boolean()

~.is.number()

~.is.float()

~.is.integer()

~.is.function()

~.is.string()

~.is.date()

~.is.promise()

~.is.action()

~.is.array()

~.is.object()

~.is.instance.of()

~.is.more.than()

~.is.more.or.equal.to()

~.is.less.than()

~.is.less.or.equal.to()

~.is.empty({string})

~.is.empty({array})

~.is.empty({object})

~.is.empty({other})

~.has({array})

~.has({string})

~.has({object})

~.has.key({array})

~.has.key({array})

~.has.keys({array})

~.has.value({array})

~.has.values({array})

~.is.not()

~.is.not.true()

~.is.not.truthy()

~.is.not.false()

~.is.not.falsy()

~.is.not.equal.to()

~.is.not.similar.to()

~.is.not.like()

~.is.not.different.from()

~.is.not.defined()

~.is.not.undefined()

~.is.not.something()

~.is.not.boolean()

~.is.not.number()

~.is.not.float()

~.is.not.integer()

~.is.not.function()

~.is.not.string()

~.is.not.date()

~.is.not.promise()

~.is.not.action()

~.is.not.array()

~.is.not.object()

~.is.not.instance.of()

~.is.not.more.than()

~.is.not.more.or.equal.to()

~.is.not.less.than()

~.is.not.less.or.equal.to()

~.is.not.empty({string})

~.is.not.empty({array})

~.is.not.empty({object})

~.is.not.empty({other})

~.has({array})

~.has({string})

~.has({object})

~.has.not.key({array})

~.has.not.key({array})

~.has.not.keys({array})

~.has.not.value({array})

~.has.not.values({array})

Conclusión

Assertivity es un framework completamente innecesario dadas las herramientas de alta calidad de hoy en día. No obstante, ninguno de ellos permite generar expresiones booleanas en una sola línea, usando una API semántica (de ahí el acercamiento natural), además de generar reportes concisos de las aseveraciones que se están haciendo y los resultados que se han obtenido.

Por tanto, aunque sea innecesario ante Jasmine, Qunit, Mocha, Chai, etc. es bueno tener una herramienta que:

· Ahorre código

· Aumente legibilidad

· Haga reportes concretos de las afirmaciones que se están haciendo.

· Se escriba, se lea y se pronuncie de la misma manera.

La misma idea que se esconde tras este proyecto, se escondía tras NaturalScript (test del lenguaje en PasteBin), un lenguaje de programación casi natural que transpilaba a JavaScript. Pero ni Google, ni Microsoft, ni Oracle, ni Intel (todos juntos, por cierto, ya que les carteé a todos juntos, y sólo recibí una respuesta de IBM) quisieron darme 5000 € para que trabajara en ello por mi cuenta durante 6 meses (pese a sus ingresos, jeje... insultantes, irrisorios ingresos y beneficios), por lo que bueno... he de suponer que esto se pudrirá. Como yo, y todos mis esfuerzos por hacer que la puta población despierte y se coma vivos a los políticos que les están metiendo en la guerra, o saqueando a los pueblos amigos.

En fin. Yo acabaré loco. Pero vivo en un mundo de absurdos, que es peor todavía.