def METHOD_NAME(cli, datafiles):
    project = str(datafiles)
    junction_path = os.path.join(project, "elements", "junction.bst")
    target_path = os.path.join(project, "elements", "junction-target.bst")
    # First, create a junction element to refer to the subproject
    junction_config = {
        "kind": "junction",
        "sources": [
            {
                "kind": "local",
                "path": "files/sub-project",
            }
        ],
    }
    _yaml.roundtrip_dump(junction_config, junction_path)
    # Then, create a stack element with dependency on cross junction element
    target_config = {"kind": "stack", "depends": ["junction.bst:dummy_subproject.bst"]}
    _yaml.roundtrip_dump(target_config, target_path)
    # Now try to perform a build
    # This should automatically fetch the junction at load time.
    result = cli.run(project=project, args=["build"])
    result.assert_success()
    assert cli.get_element_state(project, "junction.bst:dummy_subproject.bst") == "cached"
    assert cli.get_element_state(project, "junction-target.bst") == "cached"