How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • const assert = require('assert');
    
    // Generate an AssertionError to compare the error message later:
    const { message } = new assert.AssertionError({
      actual: 1,
      expected: 2,
      operator: 'strictEqual'
    });
    
    // Verify error output:
    try {
      assert.strictEqual(1, 2);
    } catch (err) {
      assert(err instanceof assert.AssertionError);
      assert.strictEqual(err.message, message);
      assert.strictEqual(err.name, 'AssertionError');
      assert.strictEqual(err.actual, 1);
      assert.strictEqual(err.expected, 2);
      assert.strictEqual(err.code, 'ERR_ASSERTION');
      assert.strictEqual(err.operator, 'strictEqual');
      assert.strictEqual(err.generatedMessage, true);
    }
    Docs
  • const assert = require('assert/strict');
    
    assert.ok(true);
    // OK
    assert.ok(1);
    // OK
    
    assert.ok();
    // AssertionError: No value argument passed to `assert.ok()`
    
    assert.ok(false, 'it\'s false');
    // AssertionError: it's false
    
    // In the repl:
    assert.ok(typeof 123 === 'string');
    // AssertionError: false == true
    
    // In a file (e.g. test.js):
    assert.ok(typeof 123 === 'string');
    // AssertionError: The expression evaluated to a falsy value:
    //
    //   assert.ok(typeof 123 === 'string')
    
    assert.ok(false);
    // AssertionError: The expression evaluated to a falsy value:
    //
    //   assert.ok(false)
    
    assert.ok(0);
    // AssertionError: The expression evaluated to a falsy value:
    //
    //   assert.ok(0)
    Docs
  • it('should generate a Java project using prompts (default asset)', async () => {
            
            //...
    let contractFile = 'src/main/java/org/example/MyPrivateAssetContract.java';
            assert.fileContent('src/main/java/org/example/MyPrivateAsset.java', /SPDX-License-Identifier: WTFPL/);
            assert.fileContent('src/main/java/org/example/MyPrivateAsset.java', /public class MyPrivateAsset {/);
            
            //...
    })
    /IBM-Blockchain/generator-fabric apache-2.0
  • it('should resolve an imported base property', () => {
                let mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration);
                mockModelManager.getType.returns(mockAssetDeclaration);
                mockAssetDeclaration.getProperty.returns(null);
                let asset = loadAssetDeclaration('test/data/parser/assetdeclaration.resolve.cto');
                should.equal(asset.getProperty('noSuchProperty'), null);
                sinon.assert.calledOnce(mockAssetDeclaration.getProperty);
                sinon.assert.calledWith(mockAssetDeclaration.getProperty, 'noSuchProperty');
            })
    /accordproject/concerto apache-2.0
  • const { uri } = await Camera.takePictureAsync();
    const asset = await MediaLibrary.createAssetAsync(uri);
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples