Featurevisor

Advanced

Tagging features

Tagging your features lets targets select smaller groups of features for generated datafiles.

Configuration

Every Featurevisor project needs to define a set of tags in the configuration file:

featurevisor.config.js
module.exports = {
tags: [
'web',
'mobile',
// add more tags here...
],
environments: [
'staging',
'production',
],
}

Defining features

Above configuration enables you to define your features against one or more tags as follows:

features/my_feature.yml
description: My feature
tags:
- web
# ...

Learn more about defining features.

Building datafiles

Tags do not create datafiles on their own. Define targets that select the tags you need:

targets/web.yml
description: Web app
tag: web

When building datafiles, Featurevisor creates datafiles for targets.

Consuming datafile

Now from your application, you can choose which datafile to load:

your-app/index.js
import { createFeaturevisor } from '@featurevisor/sdk'
const datafileUrl = 'https://cdn.yoursite.com/production/featurevisor-web.json'
const datafileContent = await fetch(datafileUrl).then((res) => res.json())
const f = createFeaturevisor({
datafile: datafileContent,
})

Learn more about SDKs.

Testing features against targets

When writing a feature's test spec, use the target property:

tests/features/my_feature.spec.yml
feature: my_feature
assertions:
- environment: production
at: 90
context:
country: nl
target: web
expectedToBeEnabled: true

The test runner builds target datafiles in memory automatically:

$ npx featurevisor test
Previous
CLI usage